I have a MYViewController
which presets the MYNavigationController
with a custom segue like
- (void)perform
{
[self.sourceViewController presentViewController:self.destinationViewController animated:NO completion:nil];
}
Also I have an unwind segue, like
- (void)perform
{
[self.sourceViewController dismissViewControllerAnimated:NO completion:nil];
}
In a storyboard there is a connection between MYNavigationController
and Exit placeholder in Navigation Controller Scene – the unwind segue with identifier unwindToVC1
.
MYNavigationController
looks like this
...
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier
{
MYCustomUnwindSegue *segue = [[MYCustomUnwindSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController];
return segue;
}
- (IBAction)unwindToVC1:(UIStoryboardSegue *)sender
{
}
- (IBAction)dissmissMYNavigationController:(id)sender
{
[self performSegueWithIdentifier:@"unwindToVC1" sender:sender];
}
...
So when I call -dissmissMYNavigationController
nothing happens. Even -segueForUnwindingToViewController:fromViewController:identifier:
isn't called.
What am I doing wrong? Thanks!
If you want to remove the top ViewController from a navigator controller you have to call popViewControllerAnimated:
. dismissViewControllerAnimated
is used when you present a modal ViewController.
Seems like it wasn't clear for me how unwinding works, so
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier
{
MYCustomUnwindSegue *segue = [[MYCustomUnwindSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController];
return segue;
}
- (IBAction)unwindToVC1:(UIStoryboardSegue *)sender
{
}
should be in MYViewController
, not in MYNavigationController
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.