Reputation: 697
I embedded a ViewController(1) into a Navigation Controller. In the Navigation Bar of this ViewController I added a button and made a control-drag-action to another ViewController (2). When starting the application and clicking the button, no push-action (show) is performed.
What I did is that I assigned a newly created class for (2) so I can customize it programmatically. I set the segue from my button in my storyboard again after assigning. It still does not work. I did not assign the button to the story-board navigation-button, because in another view-controller(3) segue it worked without that.
Do I have to assign a button method with a segue in it? But why does it work in (3)? I don't know what code I should post because the problem seems so trivial.
Edit: In the image you can see the Navigation Controller, (1) with the Map View and (2). I cant "push" from the Choose-Button to (2). Do I have to implement the Navigation Controller and add both (1) and (2) as Child View Controllers?
Upvotes: 0
Views: 797
Reputation: 501
Hey @Vancore simply follow the steps below
1. Get two view controllers Fist and Second.
2. Select First View Controller and embed in navigation controller.
3. Add button to navigation bar at right.
4. Select button on navigation bar just added then right click holding drag it to second view controller and release click.
5. Select Show.
6. Run project, it works fine without any issue.
Another way
1. Create IBAction() for button in first view controller.
2. Of first view controller select yellow round controller button. Then right click holding drag it to second view controller and release click. Select Show
3. Set identifier to segue in attribute inspector e.g. "mySegue".
4. Perform segue in IBAction method with following code
[self performSegueWithIdentifier:@"mySegue" sender:self];
Upvotes: 1
Reputation: 697
I resolved it myself.
Basically what I did was creating a custom Navigation Controller and gave him (1) and (2) as child view controllers via:
[self addChildViewController: [(1)];
[self addChildViewController: [(2)];
I don't know if that's the best approach for a storyboard-based application, but it worked for me.
Upvotes: 0