iOS开发 网页中的alert/contirm 点击方法未执行
来源:互联网 发布:淘宝云客服考试试题 编辑:程序博客网 时间:2024/06/07 15:26
- 问题:
- 项目中“积分模块”用的是大麦城网页,在交互过程中网页中的confirm(ios对应alerview)点击未执行js代码。
- 解决:
- 最终找到这个代码片段,新建Category类方法,将一下代码写入。
- 扩展:
- 可修改alert、confirm风格,也常见于网页中的提示框未拉起。
- @interface UIWebView (JavaScriptAlert)
- -(void) webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame;
- - (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame;
- @end
- @implementation UIWebView (JavaScriptAlert)
/** alert */
- - (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame
- {
- UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"助手提示" message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
- [customAlert show];
- }
- static BOOL diagStat = NO;
- static NSInteger bIdx = -1;
/** contirm */
- - (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame
- {
- UIAlertView *confirmDiag = [[UIAlertView alloc] initWithTitle:@"助手提示"
- message:message
- delegate:self
- cancelButtonTitle:@"取消"
- otherButtonTitles:@"确定", nil nil];
- [confirmDiag show];
- bIdx = -1;
- while (bIdx==-1) {
- //[NSThread sleepForTimeInterval:0.2];
- [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1f]];
- }
- if (bIdx == 0){//取消;
- diagStat = NO;
- }else if (bIdx == 1) {//确定;
- diagStat = YES;
- }
- return diagStat;
- }
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
- bIdx = buttonIndex;
- }
- @end
0 0
- iOS开发 网页中的alert/contirm 点击方法未执行
- iOS自定义相机中的button点击方法不执行
- ios 开发 去掉H5 alert 中的网址
- alert点击确定触发方法
- 自动点击网页alert()弹出框
- iOS开发中oc代码响应js网页点击事件的方法
- js 中的alert title 在 iOS 中如何消失(未测试)
- 如何设置WebView使得加载网页时能够执行JavaScript脚本中的alert()函数
- 31.ios 防止按钮快速点击造成多次响应的避免方法。 取消正在执行中的方法
- js一个方法中的两个语句中间加alert弹出和不加alert弹出执行结果不一样
- iOS开发中的公共方法
- iOS开发中的敏捷方法
- iOS UIAutomation中alert处理方法
- 模拟点击网页中的按钮
- CHtmlView,点击网页中的按钮
- 模拟点击网页中的按钮
- Delphi_Webbrowser中自动点击Alert弹出窗口中的按钮
- delphi 网页提交按钮执行点击事件
- 登陆界面的密码记住
- Python设计模式(三)--抽象工厂模式
- database基本操作
- c3p0数据源死锁
- myEclipse10编译错误
- iOS开发 网页中的alert/contirm 点击方法未执行
- lintcode——把排序数组转换为高度最小的二叉搜索树
- JS和jQuery获取和修改label的值的示例代码
- 图解正向代理、反向代理、透明代理
- EA&UML日拱一卒-关联(关联类)
- text
- poj-1125 Stockbroker Grapevine【floyd/dp经典题】
- 循环迭代24点
- ffmpeg处理RTMP流媒体的命令大全