zoukankan      html  css  js  c++  java
  • OC和JS互调

    OC和JS互调 可能造成相互强引用 小技巧

        JSContext *content = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];

        content[@"chongzhi"] = ^() {

            

            NSArray *thisArr = [JSContext currentArguments];

            int iValue = 0;

            if(thisArr.count > 0)

            {

                JSValue *value = thisArr.firstObject;

                DebugLog(@"value:%@",value);

                NSString *strValue = [value toString];

                DebugLog(@"strValue:%@",strValue);

                iValue = [strValue intValue];

                DebugLog(@"iValue:%d",iValue);

            }

            

            TopupController *vc = [[TopupController alloc] init];

            switch (iValue) {

                case 20:

                    vc.amount = 0;

                    break;

                case 50:

                    vc.amount = 1;

                    break;

                case 100:

                    vc.amount = 2;

                    break;

                case 200:

                    vc.amount = 3;

                    break;

                case 500:

                    vc.amount = 4;

                    break;

                default:

                    vc.amount = 0;

                    break;

            }

            //            vc.amount = 1;

            NSLog(@"vc.amount:%ld",vc.amount);

            dispatch_async(dispatch_get_main_queue(), ^{

            [self.navigationController pushViewController:vc animated:YES];

            });

     

    跳转时在主线程种可以解决

  • 相关阅读:
    NPOIHelper
    NPOI.dll 用法:单元格、样式、字体、颜色、行高、宽度 读写excel
    SQL中的循环、for循环、游标
    .net mvc datatables中orderby动态排序
    MVC中给TextBoxFor设置默认值和属性
    定义实体系列-@JsonIgnoreProperties注解
    微信公众号登录与微信开放平台登录区别
    http-Post请求,Post Body中的数据量过大时出现的问题
    .net core Linux 安装部署
    二、微信公众号开发-获取微信用户信息(.net版)
  • 原文地址:https://www.cnblogs.com/yulehuayuan/p/6432794.html
Copyright © 2011-2022 走看看