applicationWillResignActive and setBrightness not working?

后端 未结 6 1169
误落风尘
误落风尘 2021-01-03 20:17

I use [[UIScreen mainScreen]setBrightness: ] (in sdk 5.0) to change the system background light in my app.

The following steps work with my app:

  1. Act

6条回答
  •  一生所求
    2021-01-03 21:02

    Have you tried registering your main view controller (or whatever object as to that) for the UIApplicationWillResignActiveNotification which is sent after executing applicationWillResignActive?

    This will give you a chance to modify the brightness outside of applicationWillResignActive. Don't know if this method makes any difference, but trying it should be easy.

    Simply call:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResign) name:UIApplicationWillResignActiveNotification object:nil];
    

    then define:

    - (void)appWillResign {
        [[NSUserDefaults standardUserDefaults] floatForKey:@"sysBright"];
        [[UIScreen mainScreen] setBrightness:sysBright];        
    }
    

提交回复
热议问题