how to refresh my iPhone application

Posted on 2011-10-10
Last Modified: 2012-05-12
Dear All,

i created an application with timer to show clock the application is working fine on the iPhone after 20 seconds the iPhone will go in to sleep mode the application still working on the background but the time stop and the clock will not be correct, i did my research and i found that i can refresh the application using :

applicationdidbecomeactive  function to refresh the UI interface but am not able find how my question here how i can disable the sleep mode while my application is running to prevent the iPhone from going into sleep, how i can refresh my application like it started from the scratch using applicationdidbecomeactive function

Best regards

Question by:deniro1974
    LVL 13

    Accepted Solution

    When your application starts, add this line of code:

    [UIApplication sharedApplication].idleTimerDisabled = YES;

    Open in new window

    When it closes, add this code:

    [UIApplication sharedApplication].idleTimerDisabled = NO;

    Open in new window

    This will disable the auto-lock feature, as you would like.

    Author Comment

    can you please explain more where i can use this code in which function on the appdelegate or in the viewcontroller ?

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    A common question or need, when setting-up a new Mac for someone would be to make all of the applications, installed, available from the dock. Many people often do not realize an application is installed unless it is in the dock. Creating a custo…
    This is a short article about OS X KeRanger, and what people can do to get rid of it.
    Users will learn how resize a batch of photos from a single command in Photoshop via Photoshop's Image Processor. Open up an Image you'd like to resize in Adobe Photoshop: Adjust the image size according to your preferences. Image > Adjustments > …
    Users will learn how to set proper sequence settings, scale images, paste attributes, add transitions, fades, and music. Open up Final Cut Pro 7 and Create a new Project: Set the Sequence Settings. a) Click File > Easy Setup > Format > Apple ProRe…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now