[****ViewController respondsToSelector:]: message sent to deallocated instance
2015-02-12 23:17
369 查看
崩溃出现了,而且没有任何有效的提示,在断点处看不到断在哪里,只有在log有输出下面一句。
[****ViewController respondsToSelector:]: message sent to deallocated instance
很明显这是因为一个UIViewController释放后,又再次向这个VC调用了某些请求导致。而且根据log发现该VC是执行了dealloc方法,这就说明可能是在VC中设置了 xxx.delegate=self; 当VC释放后,这个xx还没有被释放,所以xx的回调方法还在调用delegate即这里的vc,
所以崩溃就发生了。
解决办法是在dealloc中设置xx.delegate = nil;即可。
我遇到这个crash是在当前VC中, 设置了一个scrollview.delegate=self。 而这个scrollview上放置了textfield.当textfield的键盘下动向下关闭时,则需要调整scrollview的contentOffset. 而当scrollview调整时,
又会调用delegate,让其判断是否触发了下拉刷新等操作。
上面有流程在正常情况下是没有问题,但是如果当前的textfield处于focus状态,即键盘弹起的状态,然后点击返回按钮,使当前uiviewcontroller被pop出去, 这个时候首先会触发textfield的resignKeyboard操作, resignKeyboard方法中又会去重设scrollview的contentOffset,
设置scrollview的contentOffset时,会不断触发其delegate即VC的调用, 而VC已经被释放,所以就出现了崩溃。
当然, 上面的情况也可以是当scrollView调整时, 会调起
scrollViewWillBeginDragging方法, 而在这个方法中,通常会把textfield失去焦点,而失去焦点的过程中,又会重新调整scrollView的contentoffset.
[****ViewController respondsToSelector:]: message sent to deallocated instance
很明显这是因为一个UIViewController释放后,又再次向这个VC调用了某些请求导致。而且根据log发现该VC是执行了dealloc方法,这就说明可能是在VC中设置了 xxx.delegate=self; 当VC释放后,这个xx还没有被释放,所以xx的回调方法还在调用delegate即这里的vc,
所以崩溃就发生了。
解决办法是在dealloc中设置xx.delegate = nil;即可。
我遇到这个crash是在当前VC中, 设置了一个scrollview.delegate=self。 而这个scrollview上放置了textfield.当textfield的键盘下动向下关闭时,则需要调整scrollview的contentOffset. 而当scrollview调整时,
又会调用delegate,让其判断是否触发了下拉刷新等操作。
上面有流程在正常情况下是没有问题,但是如果当前的textfield处于focus状态,即键盘弹起的状态,然后点击返回按钮,使当前uiviewcontroller被pop出去, 这个时候首先会触发textfield的resignKeyboard操作, resignKeyboard方法中又会去重设scrollview的contentOffset,
设置scrollview的contentOffset时,会不断触发其delegate即VC的调用, 而VC已经被释放,所以就出现了崩溃。
当然, 上面的情况也可以是当scrollView调整时, 会调起
scrollViewWillBeginDragging方法, 而在这个方法中,通常会把textfield失去焦点,而失去焦点的过程中,又会重新调整scrollView的contentoffset.
相关文章推荐
- [****ViewController respondsToSelector:]: message sent to deallocated instance
- [HelpViewController respondsToSelector] message sent to deallocated instance
- [**ViewController respondsToSelector:]: message sent to deallocated instance崩溃问题解决方法
- [****ViewController respondsToSelector:]: message sent to deallocated instance
- delegate---[ViewController respondsToSelector:]: message sent to deallocated instance 0x7f84
- ViewController respondsToSelector:]: message sent to deallocated instance
- iOS [xxxxController respondsToSelector:]: message sent to deallocated instance 0x1310293e0崩溃问题
- [xxx respondsToSelector:]message sent to deallocated instance和空地址崩溃 空指针
- iOS开发 [SY_InformationController respondsToSelector:]: message sent to deallocated崩溃信息
- iOS [MTMeViewController scrollViewDidScroll:]: message sent to deallocated instance
- -[xxxViewController scrollViewDidScroll:]: message sent to deallocated instance 0x7fc04
- 崩溃 [XXXX respondsToSelector:]: message sent to deallocated instance 0x7fe2d3e404f0
- ios -[MTMeViewController scrollViewDidScroll:]: message sent to deallocated instance 0x7fc0f6f2
- [****ViewController scrollViewDidScroll:]: message sent to deallocated instance 0x12d6c22f0
- *** -[AlwayedDownVC tableView:canEditRowAtIndexPath:]: message sent to deallocated instance 0x17a971
- [UIActivityIndicatorView _applicationDidEnterBackground:]: message sent to deallocated instance 0x48
- tableView滑动删除返回错误 [ tableView:canEditRowAtIndexPath:]:message sent to deallocated instance 0x10930c1
- [view release]: message sent to deallocated instance 0xe250df0
- UITextField textInputView: message sent to deallocated instance
- UIScrollView retain: message sent to deallocated instance