首页 > 移动平台 > 详细

IOS KVO没有在delloc中移除导致奔溃

时间:2019-01-30 10:48:53      阅读:397      评论:0      收藏:0      [点我收藏+]

1.背景

   为了监听tableview的移动

           [_tableView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
2.问题

  奔溃报错Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior

3.解决

   - (void)dealloc
   {
       [_tableView removeObserver:self forKeyPath:@"contentOffset" context:nil];
   }

 

IOS KVO没有在delloc中移除导致奔溃

原文:https://www.cnblogs.com/xiyangxixia/p/10336887.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!