ioswkwebviewjsalert

1.将WKWebView的WKUIDelegate设置成self。
2.将一下三个方法拷贝到项目中。

成都创新互联公司自成立以来,一直致力于为企业提供从网站策划、网站设计、成都做网站、网站建设、外贸营销网站建设、电子商务、网站推广、网站优化到为企业提供个性化软件开发等基于互联网的全面整合营销服务。公司拥有丰富的网站建设和互联网应用系统开发管理经验、成熟的应用系统解决方案、优秀的网站开发工程师团队及专业的网站设计师团队。

  • 解决alert方法
-(void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:message?:@"" preferredStyle:UIAlertControllerStyleAlert];
    [alertController addAction:([UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        completionHandler();
    }])];
    [self presentViewController:alertController animated:YES completion:nil];

}
  • 解决confirm
- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString * _Nullable))completionHandler{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:prompt message:@"" preferredStyle:UIAlertControllerStyleAlert];
    [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        textField.text = defaultText;
    }];
    [alertController addAction:([UIAlertAction actionWithTitle:@"完成" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        completionHandler(alertController.textFields[0].text?:@"");
    }])];
    [self presentViewController:alertController animated:YES completion:nil];
}
  • 解决prompt
  • (void)webView:(WKWebView )webView runJavaScriptTextInputPanelWithPrompt:(NSString )prompt defaultText:(NSString )defaultText initiatedByFrame:(WKFrameInfo )frame completionHandler:(void (^)(NSString _Nullable))completionHandler{
    UIAlertController
    alertController = [UIAlertController alertControllerWithTitle:prompt message:@"" preferredStyle:UIAlertControllerStyleAlert];
    [alertController addTextFieldWithConfigurationHandler:^(UITextField _Nonnull textField) {
    textField.text = defaultText;
    }];
    [alertController addAction:([UIAlertAction actionWithTitle:@"完成" style:UIAlertActionStyleDefault handler:^(UIAlertAction
    _Nonnull action) {completionHandler(alertController.textFields[0].text?:@"");
    br/>completionHandler(alertController.textFields[0].text?:@"");
    [self presentViewController:alertController animated:YES completion:nil];
    }

当前名称:ioswkwebviewjsalert
标题路径:http://bzwzjz.com/article/iiijhc.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 做网站设计 成都商城网站建设 LED网站设计方案 重庆电商网站建设 成都定制网站建设 营销型网站建设 企业网站设计 成都响应式网站建设 企业手机网站建设 网站设计公司 响应式网站设计方案 成都网站建设 温江网站设计 网站制作 定制级高端网站建设 攀枝花网站设计 外贸网站建设 重庆网站建设 成都网站设计 移动网站建设 成都定制网站建设 定制网站设计