iOSでバックライトを消灯させない方法

UIApplicationクラスのプロパティで設定できる。

idleTimerDisabledというプロパティをYESにすればok

UIApplication *application = [UIApplication sharedApplication];
application.idleTimerDisabled = YES;

また、

You should set this property only if necessary and should be sure to reset it to NO when the need no longer exists. Most apps should let the system turn off the screen when the idle timer elapses.

とあり他のアプリのためにアプリがバックグラウンドに回ったりした時にはちゃんとこのプロパティをNOに戻してあげないといけないらしい。

application.idleTimerDisabled = NO;

そしてiPhoneをMacにつなげてアプリをXcodeから立ち上げてる場合はロックされないらしい。ずっと待ってた時間を返せ...笑

クラスのもつプロパティってアプリごとにもってるんじゃなくてOSや端末ごとに保持してるのかな。難しいなiOS

他参考にさせていただいたサイト

iOS 用アプリケーションでバックライトを常時点灯する - 株式会社アトトック

iPhoneSDKでスリープさせない方法 - 電子ガジェットいろいろ 開発メモ

Swift - iOSアプリ起動中にスリープしないようにする - Qiita