Dra*_*ahc 3 iphone objective-c uiapplicationdelegate
我想在我的应用程序上实现此功能,但我似乎无法弄清楚如何使用这行代码.
- (void)applicationWillResignActive:(UIApplication *)application {
//our app is going to loose focus since there is an incoming call
[self pauseGame];
}
- (void)applicationDidBecomeActive:(UIApplication *)application{
//the user declined the call and is returning to our app
[self resumeGame];
}
Run Code Online (Sandbox Code Playgroud)
我已经读过这个必须放在appdelegates但我似乎无法弄清楚当游戏当前在viewcontroller中时我怎么能调用我的暂停动作.
谢谢.
您可以将它们发送给您的视图控制器,而不是将消息发送给自己(这是应用程序委托).
例如,如果您的应用程序委托具有名为"gameViewController"的主游戏视图控制器的属性(其中实现了暂停和恢复的方法):
- (void)applicationWillResignActive:(UIApplication *)application {
// our app is going to loose focus since there is an incoming call
[self.gameViewController pauseGame];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// the user declined the call and is returning to our app
[self.gameViewController resumeGame];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
620 次 |
| 最近记录: |