【问题标题】:Swift "More" controller crashesSwift“更多”控制器崩溃
【发布时间】:2022-01-04 09:06:14
【问题描述】:

我有一个带有标签栏的应用程序。因为我向它添加了 6 个 ViewController,它会自动转换为 4 个选项卡和一个“更多”控制器。这里是剩下的 2 个 ViewController 的列表。

我的问题是,当我导航到这 2 个 ViewController 之一,然后再次按“更多”选项卡时,应用程序因线程 1 崩溃:“层 是其层树中循环的一部分”。

我认为这是因为它试图在现有的 MoreViewController 中插入 MoreViewController,但是我不确定如何解决这个问题。如果有人可以帮助我,那就太好了。

提前致谢。

帕特里克

【问题讨论】:

    标签: ios swift uitabbarcontroller


    【解决方案1】:

    好吧..所以我设法创建了一个解决方法。

    在委托方法中 func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool你会在点击tabitems时收到通知。

    我检查了选择的viewController 是否是moreNavigationController。 然后if moreNavigationController.topViewController == (one of the two viewcontrollers listed in the MoreViewController) { moreNavigationController.popViewController(animated: true) }

    这将防止应用程序崩溃,并将带您返回到 MoreViewController 的 tableView。仍然是奇怪的行为。但我很高兴它不再崩溃了 :) 希望有人会发现这很有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-21
      • 2011-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多