search

Home  >  Q&A  >  body text

Objective-c - How to turn off automatic lock screen in iOS

[UIApplication sharedApplication].idleTimerDisabled = YES. After setting it, the screen will still lock after a period of time. What's going on?

世界只因有你世界只因有你2810 days ago876

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-02 09:26:01

    Put settings idleTimerDisabled的代码放到AppDelegate里的applicationDidBecomeActivein

    - (void)applicationDidEnterBackground:(UIApplication *)application {
        [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
    }
    
    - (void)applicationDidBecomeActive:(UIApplication *)application {
        [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    }

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-02 09:26:01

    Logically speaking, after you set idleTimerDisabled to YES, the screen should not be automatically locked in the current app. Where did you set it up? Can you give me a more detailed code?

    reply
    0
  • Cancelreply