質問

Why do I have to click twice on a backButtonBarItem in a NavigationController to go one view back?

I have a storyboard with the navigation controller, the tableViewController and a singleViewController.

When I click on a row in the tableViewController the viewController is loaded.

[self.navigationController pushViewController:[[self storyboard] instantiateViewControllerWithIdentifier:@"singleView"] animated:YES];

But when I click on the backButton in the singleView it switches to the singleView again. When I click a second time on the backButton in the singleView it switches to the tableView!!!

Why? How can I change it that I have only click once?

Thank you in advance.

役に立ちましたか?

解決

If you are using storyboard, then a much better way to do it is drag right click from the UITableViewCell to the UIViewController and create a Segue. When the Segue is made, you can use the delegate method below to prepare the UIViewController if it needs any data instantiated.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.destinationViewController respondsToSelector:@selector(sendDataToViewController:)])
    {
        [segue.destinationViewController sendDataToViewController:data];
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top