简体   繁体   中英

What Segue Is Called On Back Button Click?

I'm going from a table view to details view.

I'm trying to set the title of my tableview in my detailsview segue back to tableview.

I tired calling the same segue that is pushed to details view but no dice.


I use

self.navigationController.navigationBar.topItem.title = @"";

in my details view (to remove the title on the back button)

but when I go back to my TableView it also removes that title....

So I added the following code in my DetailsView segue

destinationViewController.navigationItem.title = @"Title";

but like I said I think I'm calling the wrong segue

You can Unwind segue. You need to create method in tableView (not details view) which accept UIStoryboardSegue:

- (IBAction)unwindToViewController:(UIStoryboardSegue *)segue {
    UIViewController* sourceViewController = segue.sourceViewController;
}

After that in storyboard in detail view controller you can see 'exit' icon, this is unwind segue control drag from it to that method and you will create new segue.

Unwind segue is made for deal with this kind of jobs. You can google this to find out more details.

Create Segue type "Custom" on your stroyboard. This can be from a button. Create a new UIStoryboardSegue class named "popSegue" In the popSegue.m file add the following;

-(void)perform{
    UIViewController *sourceViewContreoller = [self sourceViewController];
    [sourceViewContreoller.navigationController popViewControllerAnimated:YES];
}

-In the storyboard editor.

-Select the segue and change the Segue Class to "popSegue"

-Set the Identifier to "popSegue"

Done!

You can use the same "popSegue" class throughout your project.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM