zoukankan      html  css  js  c++  java
  • HTML调用Swift

    1. //UIWebView的代理方法拦截

       func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {self.perform(ViewController.Semethodscheme(request: request))

            return true

        }

    2.//解析协议
        static  func Semethodscheme(request: URLRequest) ->(Selector){

            let urlString: String = request.url!.absoluteString

            print("icocos:///urlString",urlString)

            var scheme: String = "icocos:///"

            //取出scheme后边的路径

                print("icocos:///scheme",scheme)

            if urlString.hasPrefix(scheme) {

                let path: String =  urlString.substring(from: scheme.characters.endIndex)

                print("icocos:///path",path)

                let array: [Any] = path.components(separatedBy: "?")

                print("icocos:///array",array)

                Tunarr = array

                let methodName: String? = (array.first as! String)

                print("icocos:///methodName",methodName as Any)

                let Semethod: Selector = NSSelectorFromString(methodName!)

                print("icocos:///Semethod",Semethod)

                 return Semethod

            }

          return NSSelectorFromString("SelectorFromString")

        }

    3.//调用方法

    func Tuneup(){

            let tune =

            ViewController.Tuneupurl()

           if  tune == "addent"{

           }else if tune == "follow"{

          }

        }

    4.//区分方法(你和后台定的规则我怎么会知道这是我的逻辑)

     static func Tuneupurl() ->(String){

        if  Tunarr?.count != 0{

        let rawJson = JSON(Tunarr![1]).rawString(String.Encoding.utf8, options: .prettyPrinted)

        let rawJsonurl = rawJson?.urlDecoded()

        let jsonDict = try? JSONSerialization.jsonObject(with: (rawJsonurl?.data(using:.utf8))!, options: .mutableLeaves)

        guard let  Tunedic = jsonDict as?[String: String], let Tune = Tunedic["Tuneupurl"] else{return ""}

            return Tune

            }

            return ""

        }

    挥毫泼墨,书写人生篇章
  • 相关阅读:
    文件流:"fopen","fclose",“ftell”"fseek","fgets","fprintf" ,“feof”,"fwrite","fread"
    “/”和“\”和feof();
    VS快捷键说明
    vs2015安装VAssistX以后,去除中文注释会有红色下划线方法
    QT5.8+vs2015配置以及qt creater中出现中文乱码解决办法之一
    将ascll码转换成数值进行运算
    二维数组---指针数组和数组指针
    source insight 4.0.086破解
    make clean 和make distclean的区别
    长歌行
  • 原文地址:https://www.cnblogs.com/Jusive/p/7743581.html
Copyright © 2011-2022 走看看