开发者

NSNotificationCenter in viewDidLoad: not working

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜