如何解决带有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 举报,一经查实,本站将立刻删除。