Search code examples
iossegueuistoryboardxcode-storyboardxcode6.1

UIStoryboard Show (e.g. push) simple inverse action to go back


In storyboard we have great feature that allow us to make Show (e.g. push). So seems the logic is next:

If we don't have navigation controller then view controller will use present modal logic. My question is there any inverse action that I can use with Show?

I have a UIButton that close current view controller screen:

- (IBAction)onTappedCloseButton:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

But in case if I don't have navigation controller, how can I simple use inverse action to go back? So my solution is to check if self.navigationController is nil then use dismissing option:

[self dismissViewControllerAnimated:YES completion:nil];

But maybe there is another cool solution like Show (e.g push). But Close (e.g. pop)?


Solution

  • Yes, you can use an unwind segue to go back, and it will be the reverse of whatever the forward segue was.