繁体   English   中英

从UINavigationController展开到UIViewController

[英]Unwind from UINavigationController to UIViewController

我有一个MYViewController ,它使用自定义segue预设了MYNavigationController

- (void)perform
{
    [self.sourceViewController presentViewController:self.destinationViewController animated:NO completion:nil];
}

我也放松一下,就像

- (void)perform
{
    [self.sourceViewController dismissViewControllerAnimated:NO completion:nil];
}

在情节MYNavigationControllerMYNavigationController和Navigation Controller Scene中的Exit占位符之间存在连接-标识为unwindToVC1的展开unwindToVC1

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];
}

...

因此,当我调用-dissmissMYNavigationController没有任何反应。 甚至-segueForUnwindingToViewController:fromViewController:identifier:也不会被调用。

我究竟做错了什么? 谢谢!

如果要从导航器控制器中删除顶部ViewController,则必须调用popViewControllerAnimated: 当您呈现模式ViewController时,将使用dismissViewControllerAnimated

似乎我不清楚如何放松,所以

- (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
{
}

应该在MYViewController ,而不在MYNavigationController

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM