Nil模态viewcontroller对象

时间:2015-03-20 11:20:26

标签: ios objective-c iphone

从我的gameScene,我用它断开连接。但实质上,它是移动viewController。

GameScene

@implementation

gameController = [[GameViewController alloc] init];

-(void)disconnect {       
    [gameController disconnectAction];
}

@interface

GameViewController *gameController;

GameViewController

@interface

#import "ConnectionsViewController.h"

-(void)disconnectAction;

@implementation

-(void)disconnectAction {
    ConnectionsViewController *game = [self.storyboard instantiateViewControllerWithIdentifier:@"ConnectionsViewController"];

    [self presentViewController:game animated:YES completion:nil];
}

但是,这会返回trying to modal a nil viewcontroller的错误。是的,故事板ID是正确的。我也试过

UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

但是,这会返回一个无故事板例外。

2 个答案:

答案 0 :(得分:0)

使用以下思考......可能对你有帮助..

-(void)disconnectAction {
    [self performSegueWithIdentifier:@"ConnectionsViewController" sender:nil];
}

Make sure that you have to set view controller relationship in your storyboard.

答案 1 :(得分:0)

我被要求设置@protocol&委托移动视图控制器的方法。

How do I present a UIViewController from SKScene?

这有很大帮助。