Completion handler passed to
-[WebViewVC webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]
was not called
原因
For user security, your app should call attention to the fact
that a specific website controls the content inthis panel.A simple forumla
for identifying the controlling website is frame.request.URL.host.
The panel should have a single OK button.
谷歌翻译:
为了用户安全,您的应用应引起注意
特定网站控制此面板中的内容。 一个简单的论坛
用于标识控制网站的是frame.request.URL.host。
该面板应具有一个“确定”按钮。
简而言之就是:苹果要求显示js的弹框(比如alert())必须在
代理方法 runJavaScriptAlertPanelWithMessage:里面 调用completionHandler() block
也就是说在你自定义的alertView 中必须要执行completionHandler()
比如
-(void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void(^)(void))completionHandler
{
TYAlertView *alertView =[TYAlertView alertViewWithTitle:@"TYAlertView" message:@"This is a message, the alert view containt text and textfiled. "];[alertView addAction:[TYAlertAction actionWithTitle:@"取消" style:TYAlertActionStyleCancle handler:^(TYAlertAction *action){NSLog(@"%@",action.title);completionHandler();}]];[alertView addAction:[TYAlertAction actionWithTitle:@"确定" style:TYAlertActionStyleDestructive handler:^(TYAlertAction *action){NSLog(@"%@",action.title);completionHandler();}]];[alertView addTextFieldWithConfigurationHandler:^(UITextField *textField){
textField.placeholder = @"请输入账号";}];[alertView addTextFieldWithConfigurationHandler:^(UITextField *textField){
textField.placeholder = @"请输入密码";}];// first way to show
TYAlertController *alertController =[TYAlertController alertControllerWithAlertView:alertView preferredStyle:TYAlertControllerStyleAlert];//alertController.alertViewOriginY = 60;[self presentViewController:alertController animated:YES completion:nil];}