how to refresh my iPhone application

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

Who is Participating?
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.
deniro1974Author Commented:
can you please explain more where i can use this code in which function on the appdelegate or in the viewcontroller ?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.