首页 > 移动平台 > 详细

[UIActivityIndicatorView _applicationDidEnterBackground:]: message sent to deallocated instance

时间:2015-07-09 13:11:06      阅读:423      评论:0      收藏:0      [点我收藏+]

[UIActivityIndicatorView _applicationDidEnterBackground:]: message sent to deallocated instance


当我们运行我的的App 时,App不会crash,可当我们一按home 键,或者锁屏时,App 就会 crash  ,利用zombie 可以捕获如上信息。由信息中可得,app 向一个已经被释放的UIActivityIndicatorView发送了一个消息,导致crash。最后检查到原来是是使用的第三方包UIKit+AFNetWorking  导致的,

再   UIActivityIndicatorView+AFNetworking.m 中,有如下代码,


-(void)dealloc

{

    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000

    [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];

    [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];

    [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];

#endif

    

    [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil];

    [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil];

}


那就很明显了,当App 进入后台,UIActivityIndicatorView 被释放,当执行这个方法,App 便被crash了。

如果大家引入UIKit+AFNetWorking 时,没有用到UIActivityIndicatorView+AFNetworking ,大可把他移除掉,这样就可以解决上面的问题了。

希望对大家有帮助。


版权声明:本文为博主原创文章,未经博主允许不得转载。

[UIActivityIndicatorView _applicationDidEnterBackground:]: message sent to deallocated instance

原文:http://blog.csdn.net/pzhtpf/article/details/46814803

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