
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
How to prevent the screen from sleeping in iOS?
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.
- Related Articles
- How to lock Screen Orientation programmatically in iOS?
- How to change screen brightness programmatically in iOS?
- How do I prevent an iOS device from going to sleep mode?
- How to programmatically prevent scrolling in WebView of iOS?
- How to align views at the bottom of the screen in iOS
- How to Prevent Systems from Phishing Attacks?
- How to Prevent Your Website from Hackers?
- How to prevent form from being submitted?
- How to Ping External host from Swift in iOS?
- How to create Picker programmatically from array in iOS?
- How to prevent buttons from submitting forms in HTML?
- How to prevent the browser from executing the default action in jQuery?
- How to access RESTFul services from iOS/iPhone?
- How to Prevent Twitter Accounts from being Hacked
- How to navigate from one view controller to another in iOS?

Advertisements