码迷,mamicode.com
首页 > 其他好文 > 详细

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_8_0

时间:2016-09-12 18:48:26      阅读:209      评论:0      收藏: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)

 

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_8_0

标签:

原文地址:http://www.cnblogs.com/songxing10000/p/5865660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!