How can I prevent the display on the iOS device from dimming and turning off?

I immerse myself in iOS development and create my own alarm clock app to familiarize myself with the platform and the SDK. I noticed that some applications for an alarm in the application store do not allow the screen to turn off and / or turn off their application. How is this implemented?

+64
ios iphone screen ipad
Aug 08 '10 at 9:40 a.m.
source share
1 answer

Add this line of code to the application delegate:

Objective-C:

[[UIApplication sharedApplication] setIdleTimerDisabled:YES]; 

Swift 2:

 UIApplication.sharedApplication().idleTimerDisabled = true 

Swift 3:

 UIApplication.shared.isIdleTimerDisabled = true 
+154
Aug 08 2018-10-10T00:
source share



All Articles