0

I have a multi-player game where I want it to start after I press a button in the menu. The problem is I don't know how to transit from the menu to the game directly after I start multiplayer.

In ViewController.m

- (IBAction)multiplayer:(id)sender {
  [Nextpeer launchDashboard];
}

In AppDelegate.m

-(void)nextpeerDidTournamentStartWithDetails:(NPTournamentStartDataContainer *)tournamentContainer {
  UIStoryboard *storyboard = self.storyboard;
  ArcadeView *svc = [storyboard instantiateViewControllerWithIdentifier:@"arcade"];
  [self presentViewController:svc animated:YES completion:nil];
  srandom(tournamentContainer.tournamentRandomSeed);
  [tournamentContainer tournamentIsGameControlled];
 }

I'm getting the error of

"Property'storyboard'not found on object of type 'AppDelegate *' and "No visible @interface for 'AppDelegate' declares the selector 'presentViewController:animated:completion:'"

How do I change from one ViewController to another ViewController using storyboard?

Normally in cocos2d, I would do like this:

CCScene *gameplayScene = [CCBReader loadAsScene:@"GamePlay"];
[[CCDirector sharedDirector] replaceScene:gameplayScene];

What's the equivalent?

BhushanK
  • 1,205
  • 6
  • 23
  • 39
  • how are you setting self.storyboard when the app loads? Why are you keeping a property for it. Typically you don't need one, you can always get it by doing something like: UIStoryBoard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil]; – Jake Hargus Sep 16 '14 at 19:25
  • The reason is because i have 3 storyboards for 2 different iPhone size and 1 for iPad. How do i correct the above code? – user3623891 Sep 16 '14 at 19:39
  • First I'd try is making sure the storyboard gets instantiated correctly. In your application did finish loading method try doing self.storyboard instead of just storyboard (given that you have a property for it). If that doesn't work put in a log statement to check to make sure the storyboard isn't nil after the first line in your nextpeerDidTournamentStartWithDetails method. – Jake Hargus Sep 16 '14 at 22:20

1 Answers1

0

How do i change from one ViewController to another ViewController using storyboard?

Typically, you'd use a segue to switch from one view controller to another. You can create a segue in your storyboard, connect it to a button, and the button will automatically trigger the segue and transition to the next view controller. As part of the segue process, the existing view controller will get a chance to "prepare" for the segue, at which point it can clean up after itself as necessary and also provide any information that the next view controller might need. Read all about it in the docs for -[UIViewController prepareForSegue:sender:].

There are a number of different ways that you can transition from one view controller to another, of course. You can push a new view controller onto a navigation stack, have a tab bar controller switch between several view controllers, present a view controller, simply remove one view controller's view hierarchy from the window and install the new one, and so on. Many of the possible transitions are provided by existing segue types, but you can also create your own custom transitions by creating your own segues.

If all this is new to you, you should probably spend some time reading through View Controller Programming Guide for iOS.

Caleb
  • 124,013
  • 19
  • 183
  • 272