【问题标题】:Terminating app due to uncaught exception, reason: 'ERROR: UIScrollView does not support multiple observers implementing由于未捕获的异常而终止应用程序,原因:'错误:UIScrollView 不支持多个观察者实现
【发布时间】:2019-02-05 10:18:22
【问题描述】:

'NSInternalInconsistencyException',原因:'错误:UIScrollView 不支持多个观察者实现 _scrollViewWillEndDraggingWithVelocity:targetContentOffset:'

我检查了所有相关问题,但没有得到确切的问题。

我有一个自定义标签栏,默认情况下选择第一个,当我们选择第二个标签并首先返回时。我让应用崩溃了。

提前致谢

【问题讨论】:

  • 你在 UINavigationBar 中使用带有 Title 的 UINavigationController 吗?
  • 是的@Mrunal 我正在使用。
  • 试试这个self.navigationBar.prefersLargeTitles = false

标签: ios swift xcode uiscrollview


【解决方案1】:

您是否手动将 KVO 添加到您的代码中?

如果有,需要添加

[[NSNotificationCenter defaultCenter] removeObserver:self]

在您的视图控制器- (void)viewWillDisappear:(BOOL)animated 方法中。

此外,您似乎正在观察滚动视图内部已经观察到的选择器,不要订阅 UIKit 内部使用的选择器

removing observers

【讨论】:

  • 不,我没有添加任何 KVO 或本地通知。
【解决方案2】:

我只是在推送时简单地替换代码,我的问题就解决了。

 self.navigationController?.navigationBar.isHidden = true
    let controller = self.storyboard?.instantiateViewController(withIdentifier: MainStoryBoard.ViewControllerIdentifiers.tabbarViewController) as! TabBarViewController
    controller.selectedIndex = 0
    self.navigationController?.pushViewController(controller, animated: true)

而不是下面的代码

 let sb = UIStoryboard(name: "Main", bundle: nil)
    let controller = sb.instantiateViewController(withIdentifier: MainStoryBoard.ViewControllerIdentifiers.tabbarViewController) as! TabBarViewController
    // Feature Tab
    controller.selectedIndex = 0
    let appdelegate = UIApplication.shared.delegate as! AppDelegate
    appdelegate.window?.rootViewController = controller
    appdelegate.window?.makeKeyAndVisible()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-05
    • 1970-01-01
    • 1970-01-01
    • 2013-04-27
    • 2021-09-17
    • 2012-07-12
    • 2021-02-03
    相关资源
    最近更新 更多