I have a button I’ve added to a UIToolBar that takes me to the next viewcontroller in my storyboard. I normally switch between UIViewControllers by ctrl-clicking the button and dragging it to the viewcontroller I want to use. Now, I’d like to:
- Run a method
- Push to the next viewcontroller
I figured I could do this in code, but the following code just crashes:
AddCharacterD20ViewController *AddD20ViewController = [[AddCharacterD20ViewController alloc] initWithNibName:@"AddCharacterD20ViewController" bundle:nil];
[self.navigationController pushViewController:AddD20ViewController animated:YES];
Here is the exception:
[AddCharacterD20ViewController_Intro Next]: unrecognized selector sent to instance 0xa56c4a0′
Anyone tell me what I’m doing wrong?
1) Create a segue in the storyboard, by dragging from your view controller (NOT from the button).
2) Give it an identifier
3) add the following code:
(make sure the action is connected to the button on the storyboard.)
4) Profit! 🙂