Xcode 4.5 ios6 button open new view in objective-c
ios, objective-c
Solution
[self performSegueWithIdentifier: @"TheSequeName" sender: self];
The @"TheSequeName" is defined when you ctrl drag a button to open a new view controller on the storyboard
If you don't use segue, there are many variants to open a new view controller. The basic one is using a separate NIB (without storyboard)
SecondViewController *view = [[SecondViewController allow] initWithNibName:@"NibName" bundle:nil];
If you declare your view controller on Storyboard, you can use
SecondViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"viewStoryboardId"];
Then you show your SecondViewController using navigation controller
[self.navigationController pushViewController:view animated:YES];
Or as modal view
[self presentModalViewController:view animated:YES];
Problem
I know how I can get a button to open a new ViewController(new class) in the storyboard by dragging and dropping. But I need a code that I can write in the .m file that opens a new View when my button is clicked. In my FirstViewController.m i got: ``` - (IBAction)button1:(id)sender { } ``` What code do i need in this to get the button to open the SecondViewController?