我正在尝试从回调块内部推送视图控制器。我要推送的视图控制器包含一个 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];
}
}];
错误信息:
bool _WebTryThreadLock(bool), 0x6b21090: 试图从除主线程或web线程之外的线程获取web lock。这可能是从辅助线程调用 UIKit 的结果。现在崩溃...
我正在使用类别NSInvocation+CWVariableArguments。