带有tableview的popToRootViewController发生崩溃

问题描述

我有一个带有5 navigationController的标签栏。我在myViewController中也有一个tableView。当我尝试在第一个navigationController的ViewWilldisappear中使用self.popToRootViewController时,它将崩溃。我还将在3 navigationController中推送相同的myViewController,并在ViewWilldisappear中使用相同的self.popToRootViewController函数效果很好。我尝试为调试设置动画true和false。两者都会导致崩溃。使第一个导航控制器popToRootViewController函数起作用的唯一方法是将iOS升级到13(iOS 12.4发生崩溃。)

有人知道为什么导航无法使用tableView弹出控制器吗?该消息表示未设置UItableView数据源。这很奇怪,因为我可以很好地推动myViewController,而且我认为pop意味着删除堆栈中的元素。

另一方面,popToRootViewController函数可以在下面的函数中很好地工作。

func tabBar(_ tabBar: UITabBar,didSelect item: UITabBarItem) {

     firstNavigationController.popToRootViewController(animated: true)

}

/// Show and hide the tab bar.
///
/// - Parameters:
///   - hidden: To hide or show.
///   - animated: To animate or not.
///   - duration: The duration of the animation.
///   - completion: The completion handler that is called once the animation is completed.
open func setBar(hidden: Bool,animated: Bool,duration: TimeInterval = 0.3,completion: ((Bool)->Void)? = nil) {
    let animations = {() -> Void in
        let safeAreaBottom: CGFloat

        if #available(iOS 11.0,*){
            safeAreaBottom = self.view.safeAreaInsets.bottom
        }else{
            safeAreaBottom = 0.0
        }

        self.buttonsContainerHeightConstraint.constant = hidden ? 0.0 : self.buttonsContainerHeightConstraintinitialConstant + safeAreaBottom
        self.view.layoutIfNeeded()
    }
    if animated {
        self.view.layoutIfNeeded()
        UIView.animate(withDuration: duration,animations: animations,completion: completion)
    }
    else {
        animations()
    }
}

日志 libc ++ abi.dylib:以类型为NSException的未捕获异常终止

屏幕截图 https://imgur.com/a/MrJdk0S

任何建议都值得赞赏。谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)