[英]Unwind from UINavigationController to UIViewController
I have a MYViewController
which presets the MYNavigationController
with a custom segue like 我有一个
MYViewController
,它使用自定义segue预设了MYNavigationController
- (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
, MYNavigationController
和Navigation Controller Scene中的Exit占位符之间存在连接-标识为unwindToVC1
的展开unwindToVC1
。
MYNavigationController
looks like this MYNavigationController
看起来像这样
...
- (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. 因此,当我调用
-dissmissMYNavigationController
没有任何反应。 Even -segueForUnwindingToViewController:fromViewController:identifier:
isn't called. 甚至
-segueForUnwindingToViewController:fromViewController:identifier:
也不会被调用。
What am I doing wrong? 我究竟做错了什么? Thanks!
谢谢!
If you want to remove the top ViewController from a navigator controller you have to call popViewControllerAnimated:
. 如果要从导航器控制器中删除顶部ViewController,则必须调用
popViewControllerAnimated:
dismissViewControllerAnimated
is used when you present a modal ViewController. 当您呈现模式ViewController时,将使用
dismissViewControllerAnimated
。
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
应该在
MYViewController
,而不在MYNavigationController
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.