Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在单独的UIViewController中处理代理_Ios_Objective C_Uiviewcontroller_Delegates_Uialertview - Fatal编程技术网

Ios 在单独的UIViewController中处理代理

Ios 在单独的UIViewController中处理代理,ios,objective-c,uiviewcontroller,delegates,uialertview,Ios,Objective C,Uiviewcontroller,Delegates,Uialertview,我目前正在开发一款精灵套件游戏,在设置/使用代理方面遇到了一些问题。我知道代理是如何工作的,但我正在尝试让用户能够玩我的游戏,一旦他们按下暂停按钮,游戏就会暂停。然后,我有一个UIAlertView出现,要求“恢复游戏”或“注册”新闻稿类型的东西。我有一个网站,我有一个新的UIViewController出现在下面,当视图控制器打开时,我希望游戏暂停,它是这样的。我的问题是,当我完成了网站,我希望游戏在那一点上恢复。我的问题: 用户点击网站上的“关闭”按钮后,让UIViewController

我目前正在开发一款精灵套件游戏,在设置/使用代理方面遇到了一些问题。我知道代理是如何工作的,但我正在尝试让用户能够玩我的游戏,一旦他们按下暂停按钮,游戏就会暂停。然后,我有一个UIAlertView出现,要求“恢复游戏”或“注册”新闻稿类型的东西。我有一个网站,我有一个新的UIViewController出现在下面,当视图控制器打开时,我希望游戏暂停,它是这样的。我的问题是,当我完成了网站,我希望游戏在那一点上恢复。我的问题:

  • 用户点击网站上的“关闭”按钮后,让UIViewController关闭,然后让SKScene.paused=no
下面是我如何着手做这件事的代码

// in the view controller class
- (IBAction)closeWebsite {
[self dismissViewControllerAnimated:YES completion:nil];
[self.delegate closeWebsiteAndResumeGame];
}
下面是我的主UIViewController类的代码,它暂停游戏

// in the main view controller
@interface ADViewController () <ADWebViewViewControllerDelegate>

- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *title = [ alertView buttonTitleAtIndex:buttonIndex];
if ([title isEqualToString:@"Resume Game"]) {
    _gamePlay.scene.paused = NO;
}
else {
    // here i load the other viewController
    ADWebViewViewController *webView;
    webView.delegate = self;

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        webView = [[ADWebViewViewController alloc] initWithNibName:@"ADWebViewViewController_iPhone" bundle:nil];
    }
    else {
        webView = [[ADWebViewViewController alloc] initWithNibName:@"ADWebViewViewController_iPad" bundle:nil];
    }
    [self presentViewController:webView animated:YES completion:nil];

}
//_gamePlay.scene.paused = NO;
}

- (void) closeWebsiteAndResumeGame {
   _gamePlay.scene.paused = NO;
}
//在主视图控制器中
@接口ADViewController()
-(无效)alertView:(UIAlertView*)alertView单击按钮索引:(NSInteger)按钮索引{
NSString*标题=[alertView buttonTitleAtIndex:buttonIndex];
如果([标题isEqualToString:@“恢复游戏”]){
_gamePlay.scene.paused=否;
}
否则{
//这里我加载另一个viewController
AdWebViewController*webView;
webView.delegate=self;
如果(用户界面习惯用法()==UIUserInterfaceIdiomPhone){
webView=[[AdWebViewController alloc]initWithNibName:@“AdWebViewController_iPhone”捆绑包:nil];
}
否则{
webView=[[AdWebViewController alloc]initWithNibName:@“AdWebViewController_iPad”捆绑包:nil];
}
[self-presentViewController:webView动画:是完成:无];
}
//_gamePlay.scene.paused=否;
}
-(无效)关闭网站和Sumegame{
_gamePlay.scene.paused=否;
}

我感谢所有的帮助

我找到了答案。我不需要使用代理。我所要做的就是在Interface Builder中链接一些项目,它工作得非常好:)