• #if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_8_0


    头文件处理

    #import <UIKit/UIKit.h>
    #if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_8_0
    #else
    #import <WebKit/WebKit.h>
    #endif

    属性处理

    @interface AdaptiveWebView ()<UIWebViewDelegate,WKNavigationDelegate>
    #if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_8_0
    @property WebViewJavascriptBridge* bridge;
    #else
    @property WKWebViewJavascriptBridge *bridge;
    #endif
    @end

    代码处理

    -(void)setUrl:(NSString *)url{
        _url = url;
        NSURLRequest *urlRequest = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:url]];
         
    #if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_8_0
        [self.webView loadRequest:urlRequest];
        _bridge = [WebViewJavascriptBridge bridgeForWebView:self.webView];
        [_bridge setWebViewDelegate:self];
    #else
        [self.wkWebView loadRequest:urlRequest];
        _bridge = [WKWebViewJavascriptBridge bridgeForWebView:self.wkWebView];
        [_bridge setWebViewDelegate:self];
    #endif
        @WeakObj(self)
  • 相关阅读:
    关键字--static
    java注解
    服务器、应用服务器、web服务器、容器
    进程和线程
    Tomcat7目录结构详解(非常详细)
    HTML小练习
    HTML学习笔记
    javaoo总结二
    javaoo总结一
    python核心-类-1
  • 原文地址:https://www.cnblogs.com/songxing10000/p/5865660.html
Copyright © 2020-2023  润新知