How to prevent the screen from sleeping in iOS?

iOSApps/ApplicationsMobile Development

In this post we will be seeing how to prevent screen from sleeping in iOS.

So, let’s get started.

Copy the below line of code in viewDidLoad method in ViewController.Swift

override func viewDidLoad() {
   super.viewDidLoad()
   // Do any additional setup after loading the view, typically from a nib.
   UIApplication.shared.isIdleTimerDisabled = true
}

Run the application, the application will never go in sleep mode.

raja
Published on 16-Dec-2019 16:58:21
Advertisements