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

Solutions Collect From Internet About “How can I prevent the display on an iOS device from dimming and turning off?”

Add this line of code on your application delegate:

Objective-C:

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

Swift 2:

UIApplication.sharedApplication().idleTimerDisabled = true

Swift 3:

UIApplication.shared.isIdleTimerDisabled = true