How can I prevent the display on an iOS device from dimming and turning off? [duplicate] How can I prevent the display on an iOS device from dimming and turning off? [duplicate] ios ios

How can I prevent the display on an iOS device from dimming and turning off? [duplicate]


Add this line of code on your application delegate:

Objective-C:

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

Swift 2:

UIApplication.sharedApplication().idleTimerDisabled = true

Swift 3, 4 & 5:

UIApplication.shared.isIdleTimerDisabled = true