Reputation: 137
I am new to storyboard, in my story board i have a button over the view controller. On click of the button i am trying to add navigation controllers view as a subview it is getting added but when i try to push using the navigation controller the app is crashing. Please help me to fix this issue. I have uploaded the source code please download it from the following Url
http://www.darrr.com/skyparts/test.zip
Upvotes: 0
Views: 2313
Reputation: 56
The great advantage of storyboard is that much work can be done in Interface Builder. So to make your code work you should do next:
-(IBAction)bttnTapped:(id)sender
. Instead of calling action method on the button touch you should add a segue by ctrl-dragging from "viewCtrl" button to Navigation Controller and choose "Modal" type of segue. -(IBAction)bttnTapped:(id)sender
.The view of your storyboard in Interface Builder should look like this: storyboard view
2.Go to ViewController.h and .m and delete the method - (IBAction)bttnTapped:(id)sender
.
3.Go to ctrl1.h and .m and delete the method - (IBAction)bttnTapped:(id)sender
.
The code should work. But I recommend to put methods - (void)viewDidLoad
and - (void)viewDidUnload
to ctrl1.m back.
If you want to run some code when the button was touched but before the view is loaded you should override the method - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
.
Upvotes: 1