UIWebView初始化创建,需要在主线程执行,否则会crash。
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSString *webViewUserAgent = [NSMutableString stringWithString:[[UIWebView new] stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]];
});
bool _WebTryThreadLock(bool), 0x170016010: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
正确的初始化,就是在主线程创建。如多线程时,防止子线程调用,最好初始化
dispatch_async(dispatch_get_main_queue(), ^{
UIWebView *webView = [UIWebView new];
});