HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 一个ContainerViewController内的UINavigationController popView的时髦大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我有一个containerView Controller,它基本上就像splitViewController一样.

我试图在containerViewController中添加一个UINavigationController,它工作得很好.

我在故事板中创建了一个UINavigationController,其中连接了一堆UIViewControllers,所有这些都通过’push’segues挂钩和链接在一起.我从故事板中取出这个NavigationController,通过代码将它粘贴在我的ContainerViewController中.然后它显示了NavigationController应该在哪里,我可以单击按钮,推送动画只发生在ContainerViewController的NavigationController框架内.

但是,如果我从NavigationController上的代码调用popViewController,它将为整个ContainerViewController设置动画.我不想要它,我想它只为NavigationController设置动画.

有谁知道它为什么这样做?

当你在ContainerViewController里面有一个UINavigationController,然后你就可以在NavigationController上使用popViewController,你如何才能使它只动画UINavigationController,而不是它所在的整个ContainerViewController?

解决方法

我也遇到过这个问题.这也影响了我的推动力.我的工作是使用代码而不是故事板segues.

- (void) switchToView:(NSString *)identifier {
    UIViewController *target = [self getOrCreateViewController:identifier];
    [self switchToViewController:target identifier:identifier];
}

// If you need to interact with the VC before it is pushed break it into 2 step process
- (UIViewController *) getOrCreateViewController:(NSString *)identifier {
    NSArray *children = [self.viewControllers filteredArrayUsingPreDicate:[NSPreDicate preDicateWithFormat:@"restorationIdentifier == %@",identifier,nil]];
    UIViewController *target = (children.count > 0 ? children[0] : [self.storyboard instantiateViewControllerWithIdentifier:identifier]);
    return target;
}

// For my use case,I always animate via push. Could modify this to pop/push as appropriate
- (void) switchToViewController:(UIViewController *)target identifier:(NSString *)identifier {
    [self setViewControllers:[self.viewControllers filteredArrayUsingPreDicate:[NSPreDicate preDicateWithFormat:@"restorationIdentifier != %@",nil]] animated:NO];
    [self pushViewController:target animated:YES];

}

有点Fugly解决方法我知道…希望我找一个更好的答案(到这里寻找一个).

本图文内容来源于网友网络收集整理提供,作为学习参使用,版权属于原作者。

大佬总结

以上是大佬教程为你收集整理的ios – 一个ContainerViewController内的UINavigationController popView的时髦全部内容,希望文章能够帮你解决ios – 一个ContainerViewController内的UINavigationController popView的时髦所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。