gpt4 book ai didi

iphone - 嵌套在 moreViewController 中的 UINavigationController 的问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:14:19 25 4
gpt4 key购买 nike

我有 UITabbarMoreController,其中包含一些 UINavigationController。这些 UINavigationControllers 然后包含我的自定义 View Controller 。

所以层次结构看起来像这样:

UITabbarController
- UINavigationController
-> my custom UIViewController
- ...(other children of UITabbarController look the same)

在我的自定义 View Controller 中,我调用了 [self parentViewController],它应该返回一个 UINavigationController。这真的发生了,我确实得到了一个 UINavigationController,但只有当特定的 UINavigationController 不在 moreNavigationController 中时。

由于我在标签栏 Controller 中有很多子 Controller ,标签栏 Controller 创建了一个 moreNavigationController。如果我打开一个位于 moreNavigationController 下的 viewcontroller 并调用 [self parentViewController],它会返回一个带有类 UIMoreNavigationController

的神秘对象

我真的需要获取作为我的 View Controller 父级的 UINavigationController,而不是 UIMoreNavigationController。另外,我尝试使用 [self navigationController] 得到相同的结果。我怎样才能引用我的 View Controller 的真正最近的父级?提前感谢您的帮助!

最佳答案

简而言之,你不能。

Apple 总是尝试优化他们的代码。他们这里的优化之一是检查其UIMoreNavigationController列表中显示的ViewController是否为UINavigationController类型。因为 UIMoreNavigationController 本身是一个 UINavigationController,所以它不想创建另一个 UINavigationController。它试图避免 UINavigationController 嵌套。

当你查看UIMoreNavigationController的头文件时你会注意到它有一个变量UINavigationController* _originalNavigationController; 这实际上是您创建并要访问的原始 UINavigationController。不幸的是你不能,因为 UIMoreNavigationController 是私有(private)的。

解决方法(丑陋)

将 NavigationController 的引用传递给它的子级,当您将它们插入它的堆栈时。

关于iphone - 嵌套在 moreViewController 中的 UINavigationController 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11965886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com