0

From my gameScene, I am using it to disconnect. But in essence, it is to move 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];
}

However, this returns the error of trying to modal a nil viewcontroller. And yes, the storyboard ID is correct. I have also tried

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

However, this returns a nil storyboard exception.

Daniel
  • 285
  • 3
  • 12

2 Answers2

0

Use below think...may be help you..

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

Make sure that you have to set view controller relationship in your storyboard.
Dipen Chudasama
  • 3,063
  • 21
  • 42
  • When you say make sure I've set a relationship, does that simply mean a storyboard ID? – Daniel Mar 20 '15 at 12:49
  • Chadasama I get a has no segue with identifier error. – Daniel Mar 20 '15 at 12:53
  • all my other viewcontrollers modal perfectly with the code I've provided. However, when trying to do it whilst an skscene is present, i've ran into this problem. – Daniel Mar 20 '15 at 13:00
  • Also, on-top of that. After the performSegue method it runs the GameViewController viewDidLoad method. Rather than moving controller. This is such a weird complex. – Daniel Mar 20 '15 at 13:07
  • This is very simple you just have to put this code and set relationship in your story board..this will work...what exactly problem you have to fetch.. ConnectionsViewController is only class..without view? – Dipen Chudasama Mar 20 '15 at 13:12
  • ConnectionsViewController is a ViewController with a view. When you say set a relationship, can you elaborate? – Daniel Mar 20 '15 at 13:21
  • maybe no problems with the code, however maybe a problem with our communication.. You're saying set a relationship in my storyboard. However, I don't know what you mean. – Daniel Mar 20 '15 at 13:25
  • mean that from one viewcontrollrt press cntrl+click and drag line to another view controller(which you have to pop) – Dipen Chudasama Mar 20 '15 at 13:26
  • then I run into a no anchor error as well as a viewcontroller identifier error. – Daniel Mar 20 '15 at 13:32
0

I was required to setup a @protocol & delegate for the method to run for moving the viewcontroller.

How do I present a UIViewController from SKScene?

This helped greatly.

Community
  • 1
  • 1
Daniel
  • 285
  • 3
  • 12