您好!欢迎来到爱源码

爱源码

热门搜索: 抖音快手短视频下载   

IOS WKWebView崩溃闪回完成处理程序已传递至-[xxwebviewcwebview:runjavascriptalertpanelwithm... [源码交易]

  • 时间:2022-08-20 00:52 编辑: 来源: 阅读:290
  • 扫一扫,手机访问
摘要:IOS WKWebView崩溃闪回完成处理程序已传递至-[xxwebviewcwebview:runjavascriptalertpanelwithm... [源码交易]
提醒完成处理程序崩溃-[webview VC webview:runjavascriptalertpanelwithmessage:initiated by frame:completion handler:]原因分析在WKWebView的WKUIDelegate回调方法中没有调用,(void () (void)) CompletionHandler和(void () (bool)) CompletionHandler,无论是YES还是No,都必须执行 如果当前的WebViewVC被删除,completionHandler还没有执行,就会报出这个崩溃提醒(我延迟了completionHandler的执行时间,崩溃现象再次出现) 该方法可以直接在代码上处理,无需添加额外的属性。可以通过在使用(void () (bool)) CompletionHandler和(void () (void)) CompletionHandler的WKUIDelegate的几个回调方法中添加判断来处理。 # pragma mark-wkuidelegate-(void)webview:(wk webview *)webview runjavascript alertpanelwithmessage:(ns string *)message initiated by frame:(wkframeinfo *)frame completion handler:(void(^)(void))completionhandler{ if([self . navigation controller visible viewcontroller]!= self){ completion handler();返回;} UIAlertController * alert controller =[UIAlertController alertcontrollerwithttitle:@ " " message:message preferred style:UIAlertControllerStyleAlert];[Alert Controller add Action:[UIAlertaction Action with title:@ " Confirm " style:UIAlertaction style cancel Handler:(UIAlertaction * Action){ completion Handler();}]];if([self . navigation controller visible view controller]= = self){[self present view controller:alert controller animated:YES completion:nil];} else { completion handler();} }//显示两个按钮,通过completionHandler回调确定客户是点击确认还是取消按钮-(void)webview:(wk webview *)webview run JavaScript confirimpanelmessage:(nsstring *)message initiated by frame:(wkframeinfo *)frame completion handler:(void(^)(bool))completionhandler{ if([self . navigation controller visible viewcontroller]!= self){ completion handler(NO);返回;} UIAlertController * alert controller =[UIAlertController alertcontrollerwithttitle:message message:nil preferred style:UIAlertControllerStyleAlert];[Alert Controller add Action:[UIAlertaction Action with title:@ " OK " style:UIAlertaction style default Handler:(UIAlertaction * _ nonnull Action){ completion Handler(yes);}]];[Alert Controller add Action:[UIAlertaction Action with title:@ " Cancel " Style:UIAlertaction Style Cancel Handler:(UIAlertaction * _ nonnull Action){ completion Handler(no);}]];if([self . navigation controller visible view controller]= = self){[self present view controller:alert controller animated:YES completion:nil];} else { completion handler(NO);} }//显示一个带有输入框和确定按钮的,回调客户通过completion handler-(void)webview输入的内容:(wk webview *)webview runjavascripttextinputpanelwithprompt:(ns string *)提示默认文本:(ns string *)default text initiated by frame:(wkframeinfo *)frame completion handler:(void(^)(nsstring * _ nullable))completion handler { if([self . navigation controller visibleviewcontroller]!= self) { completionHandler(@“错误”);返回;} UIAlertController * alert controller =[UIAlertController alertcontrollerwithttitle:@ " " message:nil preferred style:UIAlertControllerStyleAlert];[alert controller addtextfieldwithconfigurationhandler:^(uitextfield * _ nonnull textfield){ }];[Alert Controller add Action:[UIAlertaction Action with title:@ " OK " style:UIAlertaction style default Handler:(UIAlertaction * _ nonnull Action){ completion Handler(Alert Controller . text fields . lastobject . text);}]];if([self . navigation controller visible view controller]= = self){[self present view controller:alert controller animated:YES completion:nil];} else { completion handler(@ " error ");}}


  • 全部评论(0)
资讯详情页最新发布上方横幅
最新发布的资讯信息
【技术支持|常见问题】1556原创ng8文章搜索页面不齐(2024-05-01 14:43)
【技术支持|常见问题】1502企业站群-多域名跳转-多模板切换(2024-04-09 12:19)
【技术支持|常见问题】1126完美滑屏版视频只能显示10个(2024-03-29 13:37)
【技术支持|常见问题】响应式自适应代码(2024-03-24 14:23)
【技术支持|常见问题】1126完美滑屏版百度未授权使用地图api怎么办(2024-03-15 07:21)
【技术支持|常见问题】如何集成阿里通信短信接口(2024-02-19 21:48)
【技术支持|常见问题】算命网微信支付宝产品名称年份在哪修改?风水姻缘合婚配对_公司起名占卜八字算命算财运查吉凶源码(2024-01-07 12:27)
【域名/主机/服务器|】帝国CMS安装(2023-08-20 11:31)
【技术支持|常见问题】通过HTTPs测试Mozilla DNS {免费源码}(2022-11-04 10:37)
【技术支持|常见问题】别告诉我你没看过邰方这两则有思想的创意广告! (2022-11-04 10:37)

联系我们
Q Q:375457086
Q Q:526665408
电话:0755-84666665
微信:15999668636
联系客服
企业客服1 企业客服2 联系客服
86-755-84666665
手机版
手机版
扫一扫进手机版
返回顶部