Reputation: 137
I have just created a new "Master-Detail application" project I Xcode 5.
Then on my Master View Controller, I have change the table view to static, and added up a few items: Home, View 1, View 2.
I have removed the default databinding, so when i run it now it appears as intended.
As default my "Home" view is my Detail View Controller.
Now I would like: When i press "View 1" it changes my Detail View Controller to a new view I have created on my storyboard.
But how do I do that?
I have tried to push in my "View 1" but then i first have to go back to my Detail View, before I can get the menu to show up...
I guess I have to make my "View 1" the root controller?
Upvotes: 2
Views: 2180
Reputation: 1798
I recommend you to use segues. You can setup them in storyboard with Interface Builder. Just remember to use replace segues instead of push:
And the code:
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
case 0:
[self performSegueWithIdentifier:@"mainSegue" sender:self];
break;
case 1:
[self performSegueWithIdentifier:@"sheduleSegue" sender:self];
break;
case 2:
[self performSegueWithIdentifier:@"mapSegue" sender:self];
break;
}
}
Besides it, you can do some additional setup for each segue:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"mainSegue"]) {
TestViewController *dest = segue.destinationViewController;
dest.someNumber = 100500;
}
}
Upvotes: 3