Ios 无模态viewcontroller对象

Ios 无模态viewcontroller对象,ios,objective-c,iphone,Ios,Objective C,Iphone,从我的游戏场景中,我使用它来断开连接。但本质上,它是移动viewController 游戏场景 @implementation gameController = [[GameViewController alloc] init]; -(void)disconnect { [gameController disconnectAction]; } @interface GameViewController *gameController; GameViewContro

从我的游戏场景中,我使用它来断开连接。但本质上,它是移动viewController

游戏场景

@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];
}
但是,这将返回尝试对nil viewcontroller进行模态分析时出现的错误。是的,故事板ID是正确的。我也试过了

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

但是,这将返回一个无情节提要异常。

使用下面的“思考…”可能会对您有所帮助

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

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

我被要求设置一个@protocol&delegate,以便运行该方法来移动viewcontroller


这非常有帮助。

self.storyboard
nil?@Larme没错,它是从viewController运行的,viewController导入了该viewController>:|您如何显示
GameViewController
?@Larme场景是在GameViewController中显示的,即
[skView presentScene:scene]
@Larme还从我的lobbyController显示GameViewController,其方式与它尝试显示不同的viewController的方式相同。当您说“确保我已设置了关系”时,这仅仅意味着一个故事板ID吗?我得到的Chadasama没有带标识符错误的segue。我的所有其他ViewController都与我提供的代码完美匹配。然而,当我试图在一个场景出现的时候做这件事时,我遇到了这个问题。而且,最重要的是。在performsgue方法之后,它运行GameViewController viewDidLoad方法。而不是移动控制器。这是一个非常复杂的问题。这非常简单,你只需要把代码和关系放在你的故事板上就可以了。这会起作用的…你到底需要解决什么问题。。ConnectionsViewController是唯一没有视图的类?