We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0cbc5a9 commit c273a69Copy full SHA for c273a69
1 file changed
JavaScriptCore-Demo/JSCallOC/JSCallOCViewController.m
@@ -72,8 +72,12 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView
72
self.context[@"alert"] =
73
^(NSString *str)
74
{
75
- UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"msg from js" message:str delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
76
- [alert show];
+ //要把改变视图的操作放到主线程中,否则就会抛出异常,对以后的操作会有问题
+ [[NSOperationQueue mainQueue]addOperationWithBlock:^{
77
+
78
+ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:str delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
79
+ [alert show];
80
+ }];
81
};
82
83
__block typeof(self) weakSelf = self;
0 commit comments