从我的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];
但是,这会返回一个无故事板例外。
答案 0 :(得分:0)
使用以下思考......可能对你有帮助..
-(void)disconnectAction {
[self performSegueWithIdentifier:@"ConnectionsViewController" sender:nil];
}
Make sure that you have to set view controller relationship in your storyboard.
答案 1 :(得分:0)