
- 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 do I prevent an iOS device from going to sleep mode?
When most apps have no touches as user input for a short period, the system puts the device into a "sleep” state where the screen dims. This is done for the purposes of conserving power.
Preventing iOS Device from going to sleep is easy, navigate to your Settings → Display & Brightness → Autolock, select never.
This will never lock your screen.
If you’re developing an iOS Application and you’re required to implement this feature, you should use isidletimerdisabled provided by apple, to read more about it https://developer.apple.com/documentation/uikit/uiapplication/1623070-isidletimerdisabled
In your viewDidLoad method write the following line of code to prevent the device from going to sleep.
UIApplication.shared.isIdleTimerDisabled = true
- Related Articles
- How do I prevent an Android device from going to sleep mode?
- How to prevent loops going into infinite mode in Python?
- How do I load an image by URL on iOS device using Swift?
- How to prevent the screen from sleeping in iOS?
- How do I programmatically “restart” an iOS app?
- How do I prevent jQuery events from bubbling up to parent elements?
- How to lock & unlock the iOS device programmatically
- How to get device make and model on iOS?
- How to get the Touch position on iOS device?
- How to programmatically prevent scrolling in WebView of iOS?
- How do I display the current date and time in an iOS application?
- How to prevent going back to the previous activity in Android?
- How do I disable Strict Mode in MySQL?
- How do I prevent bleeding nose condition in summers?
- What do people do to prevent their cars from rusting?

Advertisements