我正在处理由其他人设计的应用程序。该应用程序是完全这样的电话:iOS冻结和线程detachNewThreadSelector
[NSThread detachNewThreadSelector:@selector(loadPhotoImage) toTarget:self withObject:nil];
和
DownloadPhotoThread *thread = [[DownloadPhotoThread alloc] initWithFriendArray:_friendsList delegate:self];
[self.arrDownloadThreads addObject:thread];
[thread start];
,并随机我将进入在整个UI锁,手机/模拟器不再响应触摸的情况。只是要清楚,该设备永远不会解冻。如果在调试会话期间暂停,我会看到一个线程正在启动或detachNewThreadSelector行。
今天,当这些锁定发生时,我能够缩小原因。我只是说了的Zendesk形式控制器(这里找到:https://github.com/zendesk/zendesk_ios_sdk/blob/master/DropboxSampleApp/FormViewController.m)
其中有这样的代码:
- (void) textViewDidChange:(UITextView *)textView
{
[self.tableView beginUpdates];
[self.tableView endUpdates];
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row > 1) {
CGSize s = [description sizeThatFits:CGSizeMake(description.frame.size.width, 10000)];
float dh = MAX(s.height, 115);
description.frame = CGRectMake(description.frame.origin.x,
description.frame.origin.y,
description.frame.size.width,
dh);
return dh;
}
return 44.0;
}
我可以很容易地通过输入字符重现锁定状态,并返回一遍又一遍这个文本框。 (此调整大小表视图的高度))
在某些情况下,我可以用一个dispatch_async包装罪犯(防止锁定状态阻止这样的:
DownloadPhotoThread *thread = [[DownloadPhotoThread alloc] initWithFriendArray:_friendsList delegate:self];
[self.arrDownloadThreads addObject:thread];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[thread start];
});
但在其他情况下,我不能,因为有问题的代码位于复杂的库中,如ASIHTTPRequest或XMPPFramework。你对这里发生了什么有什么建议吗?
另一件事。当我在这种情况下打的停顿,这就是主线程说:
Thread 1
com.apple.main-thread
0 objc_msgSend
....
25 UIApplicationMain
26 main
暂停和取消暂停总是会找到在里面objc_msgSend一些汇编指令为主。
感谢您的帮助因为我在这里严重难住。