I am building application using swift 2 targeting minimal iOS 8.
I need to present my application all the time without interrupted by device lock.
I am aware and currently using UIApplication.sharedApplication().idleTimerDisabled = true
to disable device locking.
The question is, is it possible (and how ?) to prevent device lock, but allow the screen to be dimmed (light off) ?
The goal is to save a bit more battery by turning off lcd light (without turning it off or lock device).
Thank you.
Navigate to Settings, and then tap Display. Tap the switch next to Adaptive brightness to turn the setting off. Then, adjust the Brightness bar until you've reached your desired level of brightness.
To turn off Auto-Dimming: Open Settings > Accessibility > Display & Text Size, and tap the Auto-Brightness toggle. To turn off Night Shift: Open Settings > Display & Brightness > Night Shift, and tap the Scheduled toggle. Your iPhone display will also dim when Low Power Mode activates due to the battery running low.
It may look like your iPhone 14 Pro or Pro Max keeps dimming when it transitions to Always On Display. To turn off Always On Display, open Settings and tap Display & Brightness. Scroll down and turn off the switch next to Always On.
Turn Dark Mode on or offOpen Control Center, touch and hold. , then tap. to turn Dark Mode on or off. Go to Settings > Display & Brightness, then select Dark to turn on Dark Mode or select Light to turn it off.
You cannot prevent the dimming, but you can set the brightness during the app operation. You will still disable the idle timer, but modify the brightness manually.
UIApplication.sharedApplication().idleTimerDisabled = true
UIScreen.mainScreen().brightness = CGFloat(0.1)
Few notes regarding your question:
Swift 3
UIApplication.shared.isIdleTimerDisabled = true
For my case we do not want the device to auto lock or dim. We have the snippet of code
UIApplication.sharedApplication().idleTimerDisabled = true
In Swift 4+
UIApplication.shared.isIdleTimerDisabled = true
In the view controllers that should not auto-lock or dim, yet our devices are still dimming but not auto-locking. For us this is annoying and a bug but for you it sounds like it's what you want. Although from other posts I have found:
It seems to be device specific, let me know if this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With