zoukankan      html  css  js  c++  java
  • iOS webView抓取改变js的alertView

    在webView的.h文件中:

    @interface UIWebView (JavaScriptAlert) <UIAlertViewDelegate>

     - (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(CGRect *)frame;

    @end

    在webView的.m文件中:

    @implementation UIWebView (JavaScriptAlert)

    - (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(CGRect *)frame

    {

        UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"来自九微应用的提示" message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];

        customAlert.delegate = self;

         [customAlert show];

      //由于类方法继承的是js所以无法声明变量,如果传值可以通过单例

        [InstallStatisticsClass shareInstance].strPay = message;

        NSLog(@"*******%@*********",[InstallStatisticsClass shareInstance].strPay);

    }

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

    {

        if (buttonIndex == 0) {

       //由于类方法继承的是js所以无法进行正常的push和pop,我们可以通过通知的方法进行实现

            [[NSNotificationCenter defaultCenter] postNotificationName:@"Cancellation" object:nil];

        } else {

            NSLog(@",,,,,,,,*******");

        }

        

    }

  • 相关阅读:
    git 查看、创建、切换、删除、重命名和推送分支
    Java 构造器或构造方法
    Java 二维数组
    Java 引用类型数组
    Java this关键字
    STM8S103 PB4和PB5
    RK3288 dts文件中背光配置参数
    Laravel Cache 缓存钉钉微应用的 Access Token
    Laravel View Composer
    Laravel Cache 的缓存文件在到期后是否会自动删除
  • 原文地址:https://www.cnblogs.com/anyezhuixing/p/4092574.html
Copyright © 2011-2022 走看看