2010-01-31 70 views

回答

3

根据documentation,如果设备被锁定,“applicationWillResignActive”方法将被调用。因为如此按下Command-L(或“硬件”>>“锁”“菜单中)将导致iPhone模拟器锁定,并希望触发此方法。

2

我只能得到这个代码在AppDelegate文件中工作。

你可以尝试将您的视图控制器使用NSNotificationCenter观察员

在applicationWillResign发布通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foo) name:@"AppResigned" object:nil]; 

然后,

[[NSNotificationCenter defaultCenter] postNotificationName:@"AppResigned" object:nil]; 

希望帮助!

相关问题