문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top