我试图从一个回调块内推视图控制器内执行上mainthread UIKit的电话。我想要推送的视图控制器包含一个UIWebView,它抱怨我应该在主线程上调用它。我尝试使用NSInvocation无济于事。我如何在主线程上调用presentModalViewController:animated
?如何从一个块
[vc requestUserPermissionWithCallback:^(BOOL inGranted)
{
if (inGranted)
{
if (serviceType == PXServiceTypeTwitter)
{
//[ad.rootViewController presentModalViewController:vc animated: YES]; // crashes
NSInvocation *invocation = [NSInvocation invocationWithTarget:ad.rootViewController selector:@selector(presentModalViewController:animated:) retainArguments:YES, vc, YES];
[invocation invokeOnMainThreadWaitUntilDone:NO]; // same result
}
}
else
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
}];
错误消息:
布尔_WebTryThreadLock(布尔),0x6b21090:尝试以获得比从主线程或web线程以外的线程的网络锁定。这可能是从辅助线程调用UIKit的结果。现在崩溃...
我使用的类别为NSInvocation+CWVariableArguments。
工作过,也很简单。 – Morrowless 2012-02-23 10:44:57