【问题标题】:UITableview deallocation crashes with KVO errorUITableview 释放因 KVO 错误而崩溃
【发布时间】:2017-06-13 09:44:39
【问题描述】:

我将 UITableview 用于聊天收件箱视图,我的导航堆栈就像

(
    "<VTDiscoverHome3ViewController: 0x7ff094758f00>",
    "<VTInboxViewController: 0x7ff098de34d0>",
    "<VTChatViewController: 0x7ff095827e00>",
    "<VTDiscoverProfessionalDetailsViewController: 0x7ff095424a00>",
    "<VTRequestScheduleViewController: 0x7ff095814c00>"
)

所以当我从顶视图弹出到主视图时,我在收件箱视图中遇到了崩溃,说

An instance 0x7ff094a33800 of class UITableView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x608002e3f680> (
<NSKeyValueObservance 0x60800585c1d0: Observer: 0x7ff098f1b8d0, Key path: contentOffset, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x60800585c140>
<NSKeyValueObservance 0x60800585c320: Observer: 0x7ff098f1b8d0, Key path: contentSize, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x60800585c290>
<NSKeyValueObservance 0x60800585c410: Observer: 0x7ff098f1b8d0, Key path: frame, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x60800585c380>
<NSKeyValueObservance 0x60800585c500: Observer: 0x7ff098f1b8d0, Key path: contentInset, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x60800585c470>
)'

我尝试删除tableview观察者并设置

self.tableView.delegate = nil;
self.tableView.dataSource = nil;
self.tableView = nil;

但仍然没有运气

我不明白为什么会发生这种崩溃。

任何帮助都会非常感激。

谢谢。

【问题讨论】:

  • 您是否为上述 ViewController 的任何属性添加了任何键值观察器?
  • 不,我没有。
  • 你是如何删除tableViewobservers
  • [self.tableView removeFromSuperView]; 试试这个,,,,,
  • @K.R.SaravanaKumar 如果我删除 tableview 观察者应用程序崩溃说这些属性没有添加为观察者。

标签: ios objective-c uitableview uinavigationcontroller dealloc


【解决方案1】:

找到解决方案。

我正在使用拉动刷新类,它将一些观察者添加到tableviewscrollview

所以有时在释放时它会崩溃。

因此,在删除 observers 时添加了 trycatch 块。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-08
    • 2020-06-04
    • 1970-01-01
    • 1970-01-01
    • 2017-09-28
    • 2017-08-21
    • 2014-01-20
    • 2018-09-11
    相关资源
    最近更新 更多