iPhone - phone goes to sleep even if idleTimerDisabled is YES

前端 未结 9 1358
难免孤独
难免孤独 2020-11-30 03:45

I am using this in my appdelegate\'s applicationDidFinishLaunching: method to make sure the iPhone doesn\'t go to sleep during the time the app is open

[appl         


        
相关标签:
9条回答
  • 2020-11-30 04:10

    I think the setIdleTimerDisabled doesn't exist in UIApplication class. Property searches not only set- method but also other similar named methods.

    Use dot accessor is the best way to solve your problem.

    0 讨论(0)
  • 2020-11-30 04:12

    i had the same problem. i need to make the screen dim, but when turn off the camera, the iphone goes to sleep.

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [super viewWillDisappear:animated];
        [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
    }
    

    Then i call it after turn on/off the camera, it works.

    [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    
    0 讨论(0)
  • 2020-11-30 04:16

    I set and un-set this property throughout my app using:

    [UIApplication sharedApplication].idleTimerDisabled = YES;
    

    Setting this where you're having trouble could fix it, though it might be a bit of a band-aid solution.

    0 讨论(0)
提交回复
热议问题