ios – 从后台线程显示的UIAlertView和没有委托创建EXC_BAD_ACCESS

前端之家收集整理的这篇文章主要介绍了ios – 从后台线程显示的UIAlertView和没有委托创建EXC_BAD_ACCESS前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的代码
#ifdef DEBUG
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"ERROR" message:@"JSON Parsing Error" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
    [alertView release];
#endif

代码后台线程中执行(负责解析),错误只发生在其他时间.任何想法在这里有什么问题?

解决方法

不要从后台线程弄乱UI.在主线程上创建一个方法调用方法
[someObject performSelectorOnMainThread:@selector(showDebug:)
                             withObject:@"JSON Parsing Error"
                          waitUntilDone:YES];
原文链接:https://www.f2er.com/iOS/329182.html

猜你在找的iOS相关文章