Storyboard prepareForSegue

后端 未结 1 546
灰色年华
灰色年华 2021-01-21 15:59

I have a question regarding storyboard segues. Platform is iOS 6.1. Target device is iPhone. IDE is Xcode 4.5.2. What I have are 2 TableViewControllers, both of which have a

相关标签:
1条回答
  • 2021-01-21 16:30

    When you push a view controller using a Navigation view controller, it will be pushed on the top of a stack with view controllers.

    So all you have to do get back to the previous view controller is to pop the one that got pushed.

    Put this in your IBAction method:

    [self.navigationController popViewControllerAnimated:YES];
    

    Now, if you really want to know what segue that was used, you can just pass the segue identifier to the destination controller, and put it in a property like this:

    
    -(void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender
    {
        if([[segue identifier] isEqualToString:@"segOne"])
        {
            MyOtherViewController *other = (MyOtherViewController *)segue.destinationViewController;
            other.theSegueIUsed = @"segOne";
        }
    }
    

    You also need to add the property to the other view controllers header file:

    @property (strong, nonatomic)NSString *theSegueIUsed;
    
    0 讨论(0)
提交回复
热议问题