开发者

NSNotificationCenter in viewDidLoad: not working

开发者 https://www.devze.com 2023-03-02 01:41 出处:网络
for some reason this c开发者_高级运维ode isn\'t working in viewDidLoad, but will work in viewWillAppear. Any ideas?

for some reason this c开发者_高级运维ode isn't working in viewDidLoad, but will work in viewWillAppear. Any ideas?

[[NSNotificationCenter defaultCenter] 
           addObserver:self 
              selector:@selector(wakeUp:)
                  name:UIApplicationWillEnterForegroundNotification
                object:nil];

Thank you


you're definitely sure viewDidLoad is being invoked?


For my case is that I put the removeObserver method inside didReceiveMemoryWarning method, and if I take a picture or do something else, this method fires out of my expect. So, now I always remove notification observer at dealloc stage.

0

精彩评论

暂无评论...
验证码 换一张
取 消