├── SureWebViewController
├── SureWebViewController
│ ├── sure_placeholder_error@2x.png
│ ├── sure_placeholder_error@3x.png
│ ├── ViewController.h
│ ├── AppDelegate.h
│ ├── main.m
│ ├── SureWebViewController.h
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── ViewController.m
│ ├── Info.plist
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── AppDelegate.m
│ └── SureWebViewController.m
└── SureWebViewController.xcodeproj
│ ├── xcuserdata
│ └── liushuo.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── SureWebViewController.xcscheme
│ ├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── liushuo.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
│ └── project.pbxproj
└── README.md
/SureWebViewController/SureWebViewController/sure_placeholder_error@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LSure/SureWebViewController/HEAD/SureWebViewController/SureWebViewController/sure_placeholder_error@2x.png
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/sure_placeholder_error@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LSure/SureWebViewController/HEAD/SureWebViewController/SureWebViewController/sure_placeholder_error@3x.png
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController.xcodeproj/xcuserdata/liushuo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController.xcodeproj/project.xcworkspace/xcuserdata/liushuo.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LSure/SureWebViewController/HEAD/SureWebViewController/SureWebViewController.xcodeproj/project.xcworkspace/xcuserdata/liushuo.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // SureWebViewController
4 | //
5 | // Created by 刘硕 on 2016/12/13.
6 | // Copyright © 2016年 刘硕. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // SureWebViewController
4 | //
5 | // Created by 刘硕 on 2016/12/13.
6 | // Copyright © 2016年 刘硕. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SureWebViewController
4 | //
5 | // Created by 刘硕 on 2016/12/13.
6 | // Copyright © 2016年 刘硕. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/SureWebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SureWebViewController.h
3 | // SureWebViewController
4 | //
5 | // Created by 刘硕 on 2016/12/13.
6 | // Copyright © 2016年 刘硕. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SureWebViewController : UIViewController
12 |
13 | @property (nonatomic, copy) NSString *url;
14 |
15 | @property (nonatomic, assign) BOOL canDownRefresh;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController.xcodeproj/xcuserdata/liushuo.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | SureWebViewController.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 8831A8BA1DFFA2410039B63A
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // SureWebViewController
4 | //
5 | // Created by 刘硕 on 2016/12/13.
6 | // Copyright © 2016年 刘硕. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "SureWebViewController.h"
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | // Do any additional setup after loading the view, typically from a nib.
21 | }
22 |
23 | - (IBAction)enterWebViewController:(id)sender {
24 | SureWebViewController *surevc = [[SureWebViewController alloc]init];
25 | surevc.url = @"https://www.baidu.com";
26 | surevc.canDownRefresh = YES;
27 | [self.navigationController pushViewController:surevc animated:YES];
28 | }
29 |
30 | - (void)didReceiveMemoryWarning {
31 | [super didReceiveMemoryWarning];
32 | // Dispose of any resources that can be recreated.
33 | }
34 |
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | NSAppTransportSecurity
24 |
25 | NSAllowsArbitraryLoads
26 |
27 |
28 | UILaunchStoryboardName
29 | LaunchScreen
30 | UIMainStoryboardFile
31 | Main
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // SureWebViewController
4 | //
5 | // Created by 刘硕 on 2016/12/13.
6 | // Copyright © 2016年 刘硕. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | //#import "SureRootNaviViewController.h"
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | [[UINavigationBar appearance]setBarStyle:UIBarStyleBlack];
21 | [[UINavigationBar appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
22 | [[UINavigationBar appearance]setTintColor:[UIColor whiteColor]];
23 | return YES;
24 | }
25 |
26 |
27 | - (void)applicationWillResignActive:(UIApplication *)application {
28 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
29 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
30 | }
31 |
32 |
33 | - (void)applicationDidEnterBackground:(UIApplication *)application {
34 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
35 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
36 | }
37 |
38 |
39 | - (void)applicationWillEnterForeground:(UIApplication *)application {
40 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
41 | }
42 |
43 |
44 | - (void)applicationDidBecomeActive:(UIApplication *)application {
45 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
46 | }
47 |
48 |
49 | - (void)applicationWillTerminate:(UIApplication *)application {
50 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
51 | }
52 |
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController.xcodeproj/xcuserdata/liushuo.xcuserdatad/xcschemes/SureWebViewController.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
69 |
70 |
71 |
72 |
73 |
74 |
80 |
82 |
88 |
89 |
90 |
91 |
93 |
94 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SureWebViewController
2 | ######前言
3 | 随着H5的发展,在iOS开发中,网页视图的使用率逐渐提升,为了增加代码封装度、减轻开发负担,因此通常会对网页视图进行通用类的封装,本文简单讲述网页视图控制器通用类的封装流程,希望对大家有所帮助。
4 |
5 | 本文与上篇[《一劳永逸,iOS引导蒙版封装流程》](http://www.jianshu.com/p/dfc3ecdd5810)为同一系列,均为通用类封装流程分享,欢迎感兴趣的朋友前往阅读。
6 |
7 | ######需要解决的问题:
8 | - 版本适配(UIWebView&&WKWebView)
9 | - 导航按钮快捷设置(返回&&关闭)
10 | - 修复自定义导航按钮侧滑手势失效问题
11 | - 侧滑手势返回上层网页功能
12 | - 网页加载进度显示
13 | - 网页下拉刷新
14 | - 请求异常占位图
15 |
16 | ######效果图演示
17 | 
18 | ######一、版本适配问题
19 | 在真实的开发中我们可能对UIWebView“爱不释手”,因其调用简单,使用方便,但其会占用程序的大量内存,加载速度慢,体验效果并不是很好,WKWebView为iOS8推出的网页展示视图,相比UIWebView,其占用的内存更小,请求效率更高,因此极力推荐大家使用WKWebView。
20 |
21 | 因此在网页视图的创建方面首先进行版本适配,对于大于iOS8的系统我们采用WKWebView,反之使用UIWebView。
22 | ```
23 | - (void)createWebView {
24 | self.automaticallyAdjustsScrollViewInsets = NO;
25 | if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 8.0) {
26 | [self.view addSubview:self.wk_WebView];
27 | } else {
28 | [self.view addSubview:self.webView];
29 | }
30 | }
31 |
32 | ```
33 | ######二、导航按钮快捷设置(返回&&关闭)
34 | 该功能的实现比较简单,我们可以根据webView或wk_webView的goBack方法进行判断,检测当前网页是否存在可返回的上一界面,若存在显示返回与关闭按钮,若不存在显示返回按钮即可。
35 | ```
36 | - (void)showLeftBarButtonItem {
37 | if ([_webView canGoBack] || [_wk_WebView canGoBack]) {
38 | self.navigationItem.leftBarButtonItems = @[self.backBarButtonItem,self.closeBarButtonItem];
39 | } else {
40 | self.navigationItem.leftBarButtonItem = self.backBarButtonItem;
41 | }
42 | }
43 | ```
44 | closeBarButtonItem所处理的事件为关闭界面操作即
45 | ```
46 | - (void)close:(UIBarButtonItem*)item {
47 | [self.navigationController popViewControllerAnimated:YES];
48 | }
49 | ```
50 | backBarButtonItem需根据网页是否可返回前一界面触发返回前界面或关闭操作
51 | ```
52 | - (void)back:(UIBarButtonItem*)item {
53 | if ([_webView canGoBack] || [_wk_WebView canGoBack]) {
54 | [_webView goBack];
55 | [_wk_WebView goBack];
56 | } else {
57 | [self.navigationController popViewControllerAnimated:YES];
58 | }
59 | }
60 | ```
61 | 在这里我们也可以对导航栏标题进行设置,使其为当前网页标题,在网页加载完成方法中简单调用JS语句document.title即可,webView与WkWebView调用JS方法有所区别,如下代码所示:
62 | ```
63 | //WebView
64 | self.navigationItem.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
65 | ```
66 |
67 | ```
68 | //WkWebView
69 | [webView evaluateJavaScript:@"document.title" completionHandler:^(id _Nullable title, NSError * _Nullable error) {
70 | self.navigationItem.title = title;
71 | }];
72 | ```
73 | 对于WKWebView我们还可以通过监听title属性进行实现。
74 | ######三、修复自定义导航按钮侧滑手势失效
75 | 在第二步我们手动设置了导航栏左按钮,因此我们会发现系统自带的侧滑返回功能失效了,为了可实现网页的侧滑返回功能,我们需要修复其失效的问题。
76 | ```
77 | - (void)viewWillAppear:(BOOL)animated {
78 | [super viewWillAppear:animated];
79 | if (self.navigationController.viewControllers.count > 1) {
80 | self.delegate = self.navigationController.interactivePopGestureRecognizer.delegate;
81 | self.navigationController.interactivePopGestureRecognizer.delegate = self;
82 | }
83 | }
84 |
85 | - (void)viewWillDisappear:(BOOL)animated {
86 | [super viewWillDisappear:animated];
87 | self.navigationController.interactivePopGestureRecognizer.delegate = self.delegate;
88 | }
89 |
90 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
91 | return self.navigationController.viewControllers.count > 1;
92 | }
93 |
94 | - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
95 | return self.navigationController.viewControllers.count > 1;
96 | }
97 | ```
98 | ######四、侧滑手势返回上层网页功能
99 | 对于WKWebView系统为我们提供了很好的一种实现效果,设置WkWebView的allowsBackForwardNavigationGestures为YES即可开启屏幕左边缘右滑返回与屏幕右边缘左滑返回效果。(PS:楼主曾花费一整天的时间尝试实现这个效果,没想到苹果已准备好了(╯‵□′)╯︵┻━┻ )
100 | ```
101 | _wk_WebView.allowsBackForwardNavigationGestures = YES;
102 | ```
103 | ######五、网页加载进度显示功能
104 | 对于WKWebView我们可以使用KVO监听属性estimatedProgress即可获取加载进度的变化,而对于UIWebView推荐使用[NJKWebViewProgress](https://github.com/ninjinkun/NJKWebViewProgress)进行添加。
105 | ```
106 | [_wk_WebView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:NULL];
107 |
108 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
109 | if ([keyPath isEqualToString:@"estimatedProgress"]) {
110 | _loadingProgressView.progress = [change[@"new"] floatValue];
111 | if (_loadingProgressView.progress == 1.0) {
112 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
113 | _loadingProgressView.hidden = YES;
114 | });
115 | }
116 | }
117 | }
118 | ```
119 | 既然添加了监听,因此不要忘记在dealloc中进行移除
120 | ```
121 | - (void)dealloc {
122 | [_wk_WebView removeObserver:self forKeyPath:@"estimatedProgress"];
123 | }
124 | ```
125 | ######六、网页下拉刷新(iOS10新特性)
126 | iOS10中为ScrollView添加了下拉刷新控件,而WebView里层控件即为ScrollView,因此我们可以为网页添加下拉刷新功能。这里选择使用系统原生控件UIRefreshControl,考虑某些网页页面并不需要下拉刷新功能,因此已公开BOOL加以限制,如需要可手动置为YES。
127 | ```
128 | //添加下拉刷新
129 | if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 10.0 && _canDownRefresh) {
130 | _wk_WebView.scrollView.refreshControl = self.refreshControl;
131 | }
132 | ```
133 | ######七、请求异常占位图问题
134 | 在网址请求失败或显示空白页面时需显示占位图提示用户。我们分别需要在网页请求失败以及开始加载时加以判断。以WKWebView为例。
135 | ```
136 | - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error{
137 | webView.hidden = YES;
138 | }
139 | - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation{
140 | webView.hidden = NO;
141 | _loadingProgressView.hidden = NO;
142 | //不加在空白网页
143 | if ([webView.URL.scheme isEqual:@"about"]) {
144 | webView.hidden = YES;
145 | }
146 | }
147 | ```
148 | 至此,一个简单的网页视图控制器即初步封装完毕,后续会添加JS交互及HTTPS认证等模块。
149 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController/SureWebViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SureWebViewController.m
3 | // SureWebViewController
4 | //
5 | // Created by 刘硕 on 2016/12/13.
6 | // Copyright © 2016年 刘硕. All rights reserved.
7 | //
8 |
9 | #import "SureWebViewController.h"
10 | #import
11 | static CGFloat const NAVI_HEIGHT = 64;
12 | @interface SureWebViewController ()
13 | @property (nonatomic, strong) WKWebView *wk_WebView;
14 | @property (nonatomic, strong) UIWebView *webView;
15 | @property (nonatomic, strong) UIBarButtonItem *backBarButtonItem;
16 | @property (nonatomic, strong) UIBarButtonItem *closeBarButtonItem;
17 | @property (nonatomic, strong) id delegate;
18 | @property (nonatomic, strong) UIRefreshControl *refreshControl;
19 | @property (nonatomic, strong) UIProgressView *loadingProgressView;
20 | @property (nonatomic, strong) UIButton *reloadButton;
21 | @end
22 |
23 | @implementation SureWebViewController
24 |
25 | - (void)viewDidLoad {
26 | [super viewDidLoad];
27 |
28 | [self createWebView];
29 | [self createNaviItem];
30 | [self loadRequest];
31 | // Do any additional setup after loading the view.
32 | }
33 | #pragma mark 版本适配
34 | - (void)createWebView {
35 | self.view.backgroundColor = [UIColor whiteColor];
36 | self.automaticallyAdjustsScrollViewInsets = NO;
37 | [self.view addSubview:self.reloadButton];
38 | if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 8.0) {
39 | [self.view addSubview:self.wk_WebView];
40 | [self.view addSubview:self.loadingProgressView];
41 | } else {
42 | [self.view addSubview:self.webView];
43 | }
44 | }
45 |
46 | - (UIWebView*)webView {
47 | if (!_webView) {
48 | _webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, NAVI_HEIGHT, self.view.bounds.size.width, self.view.bounds.size.height - NAVI_HEIGHT)];
49 | _webView.delegate = self;
50 | if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 10.0 && _canDownRefresh) {
51 | _webView.scrollView.refreshControl = self.refreshControl;
52 | }
53 | }
54 | return _webView;
55 | }
56 |
57 | - (WKWebView*)wk_WebView {
58 | if (!_wk_WebView) {
59 | WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc]init];
60 | config.preferences = [[WKPreferences alloc]init];
61 | config.userContentController = [[WKUserContentController alloc]init];
62 | _wk_WebView = [[WKWebView alloc]initWithFrame:CGRectMake(0, NAVI_HEIGHT, self.view.bounds.size.width, self.view.bounds.size.height - NAVI_HEIGHT) configuration:config];
63 | _wk_WebView.navigationDelegate = self;
64 | _wk_WebView.UIDelegate = self;
65 | //添加此属性可触发侧滑返回上一网页与下一网页操作
66 | _wk_WebView.allowsBackForwardNavigationGestures = YES;
67 | //下拉刷新
68 | if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 10.0 && _canDownRefresh) {
69 | _wk_WebView.scrollView.refreshControl = self.refreshControl;
70 | }
71 | //进度监听
72 | [_wk_WebView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:NULL];
73 | }
74 | return _wk_WebView;
75 | }
76 |
77 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
78 | if ([keyPath isEqualToString:@"estimatedProgress"]) {
79 | _loadingProgressView.progress = [change[@"new"] floatValue];
80 | if (_loadingProgressView.progress == 1.0) {
81 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
82 | _loadingProgressView.hidden = YES;
83 | });
84 | }
85 | }
86 | }
87 |
88 | - (void)dealloc {
89 | [_wk_WebView removeObserver:self forKeyPath:@"estimatedProgress"];
90 | [_wk_WebView stopLoading];
91 | [_webView stopLoading];
92 | _wk_WebView.UIDelegate = nil;
93 | _wk_WebView.navigationDelegate = nil;
94 | _webView.delegate = nil;
95 | }
96 |
97 |
98 | - (UIProgressView*)loadingProgressView {
99 | if (!_loadingProgressView) {
100 | _loadingProgressView = [[UIProgressView alloc]initWithFrame:CGRectMake(0, NAVI_HEIGHT, self.view.bounds.size.width, 2)];
101 | _loadingProgressView.progressTintColor = [UIColor greenColor];
102 | }
103 | return _loadingProgressView;
104 | }
105 |
106 | - (UIRefreshControl*)refreshControl {
107 | if (!_refreshControl) {
108 | _refreshControl = [[UIRefreshControl alloc]init];
109 | [_refreshControl addTarget:self action:@selector(webViewReload) forControlEvents:UIControlEventValueChanged];
110 | }
111 | return _refreshControl;
112 | }
113 |
114 | - (void)webViewReload {
115 | [_webView reload];
116 | [_wk_WebView reload];
117 | }
118 |
119 | - (UIButton*)reloadButton {
120 | if (!_reloadButton) {
121 | _reloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
122 | _reloadButton.frame = CGRectMake(0, 0, 150, 150);
123 | _reloadButton.center = self.view.center;
124 | _reloadButton.layer.cornerRadius = 75.0;
125 | [_reloadButton setBackgroundImage:[UIImage imageNamed:@"sure_placeholder_error"] forState:UIControlStateNormal];
126 | [_reloadButton setTitle:@"您的网络有问题,请检查您的网络设置" forState:UIControlStateNormal];
127 | [_reloadButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
128 | [_reloadButton setTitleEdgeInsets:UIEdgeInsetsMake(200, -50, 0, -50)];
129 | _reloadButton.titleLabel.numberOfLines = 0;
130 | _reloadButton.titleLabel.textAlignment = NSTextAlignmentCenter;
131 | CGRect rect = _reloadButton.frame;
132 | rect.origin.y -= 100;
133 | _reloadButton.frame = rect;
134 | _reloadButton.enabled = NO;
135 | }
136 | return _reloadButton;
137 | }
138 |
139 | #pragma mark 导航按钮
140 | - (void)createNaviItem {
141 | [self showLeftBarButtonItem];
142 | [self showRightBarButtonItem];
143 | }
144 |
145 | - (void)showLeftBarButtonItem {
146 | if ([_webView canGoBack] || [_wk_WebView canGoBack]) {
147 | self.navigationItem.leftBarButtonItems = @[self.backBarButtonItem,self.closeBarButtonItem];
148 | } else {
149 | self.navigationItem.leftBarButtonItem = self.backBarButtonItem;
150 | }
151 | }
152 |
153 | - (void)showRightBarButtonItem {
154 |
155 | }
156 |
157 | - (UIBarButtonItem*)backBarButtonItem {
158 | if (!_backBarButtonItem) {
159 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
160 | [button setImage:[UIImage imageNamed:@"webview_back"] forState:UIControlStateNormal];
161 | _backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(back:)];
162 | }
163 | return _backBarButtonItem;
164 | }
165 |
166 | - (UIBarButtonItem*)closeBarButtonItem {
167 | if (!_closeBarButtonItem) {
168 | _closeBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:self action:@selector(close:)];
169 | }
170 | return _closeBarButtonItem;
171 | }
172 |
173 | - (void)back:(UIBarButtonItem*)item {
174 | if ([_webView canGoBack] || [_wk_WebView canGoBack]) {
175 | [_webView goBack];
176 | [_wk_WebView goBack];
177 | } else {
178 | [self.navigationController popViewControllerAnimated:YES];
179 | }
180 | }
181 |
182 | - (void)close:(UIBarButtonItem*)item {
183 | [self.navigationController popViewControllerAnimated:YES];
184 | }
185 |
186 | #pragma mark 自定义导航按钮支持侧滑手势处理
187 | - (void)viewWillAppear:(BOOL)animated {
188 | [super viewWillAppear:animated];
189 | if (self.navigationController.viewControllers.count > 1) {
190 | self.delegate = self.navigationController.interactivePopGestureRecognizer.delegate;
191 | self.navigationController.interactivePopGestureRecognizer.delegate = self;
192 | }
193 | }
194 |
195 | - (void)viewWillDisappear:(BOOL)animated {
196 | [super viewWillDisappear:animated];
197 | self.navigationController.interactivePopGestureRecognizer.delegate = self.delegate;
198 | }
199 |
200 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
201 | return self.navigationController.viewControllers.count > 1;
202 | }
203 |
204 | - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
205 | return self.navigationController.viewControllers.count > 1;
206 | }
207 |
208 | #pragma mark 加载请求
209 | - (void)loadRequest {
210 | if (![self.url hasPrefix:@"http"]) {//是否具有http前缀
211 | self.url = [NSString stringWithFormat:@"http://%@",self.url];
212 | }
213 | if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 8.0) {
214 | [_wk_WebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
215 | } else {
216 | [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
217 | }
218 | }
219 |
220 | #pragma mark WebViewDelegate
221 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
222 | webView.hidden = NO;
223 | // 不加载空白网址
224 | if ([request.URL.scheme isEqual:@"about"]) {
225 | webView.hidden = YES;
226 | return NO;
227 | }
228 | return YES;
229 | }
230 |
231 | - (void)webViewDidFinishLoad:(UIWebView *)webView {
232 | //导航栏配置
233 | self.navigationItem.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
234 | [self showLeftBarButtonItem];
235 | [_refreshControl endRefreshing];
236 | }
237 |
238 | - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
239 | webView.hidden = YES;
240 | }
241 |
242 | #pragma mark WKNavigationDelegate
243 |
244 | #pragma mark 加载状态回调
245 | //页面开始加载
246 | - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation{
247 | webView.hidden = NO;
248 | _loadingProgressView.hidden = NO;
249 | if ([webView.URL.scheme isEqual:@"about"]) {
250 | webView.hidden = YES;
251 | }
252 | }
253 |
254 | //页面加载完成
255 | - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
256 | //导航栏配置
257 | [webView evaluateJavaScript:@"document.title" completionHandler:^(id _Nullable title, NSError * _Nullable error) {
258 | self.navigationItem.title = title;
259 | }];
260 |
261 | [self showLeftBarButtonItem];
262 |
263 | [_refreshControl endRefreshing];
264 | }
265 |
266 | //页面加载失败
267 | - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error{
268 | webView.hidden = YES;
269 | }
270 |
271 | //HTTPS认证
272 | - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler {
273 | if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
274 | if ([challenge previousFailureCount] == 0) {
275 | NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
276 | completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
277 | } else {
278 | completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
279 | }
280 | } else {
281 | completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
282 | }
283 | }
284 |
285 | - (void)didReceiveMemoryWarning {
286 | [super didReceiveMemoryWarning];
287 | // Dispose of any resources that can be recreated.
288 | }
289 |
290 | /*
291 | #pragma mark - Navigation
292 |
293 | // In a storyboard-based application, you will often want to do a little preparation before navigation
294 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
295 | // Get the new view controller using [segue destinationViewController].
296 | // Pass the selected object to the new view controller.
297 | }
298 | */
299 |
300 | @end
301 |
--------------------------------------------------------------------------------
/SureWebViewController/SureWebViewController.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 8831A8C01DFFA2410039B63A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8831A8BF1DFFA2410039B63A /* main.m */; };
11 | 8831A8C31DFFA2410039B63A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8831A8C21DFFA2410039B63A /* AppDelegate.m */; };
12 | 8831A8C61DFFA2410039B63A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8831A8C51DFFA2410039B63A /* ViewController.m */; };
13 | 8831A8C91DFFA2410039B63A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8831A8C71DFFA2410039B63A /* Main.storyboard */; };
14 | 8831A8CB1DFFA2410039B63A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8831A8CA1DFFA2410039B63A /* Assets.xcassets */; };
15 | 8831A8CE1DFFA2410039B63A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8831A8CC1DFFA2410039B63A /* LaunchScreen.storyboard */; };
16 | 8831A8D71DFFA3180039B63A /* SureWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8831A8D61DFFA3180039B63A /* SureWebViewController.m */; };
17 | 88E8855C1E0393B00010B40A /* sure_placeholder_error@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 88E8855A1E0393B00010B40A /* sure_placeholder_error@2x.png */; };
18 | 88E8855D1E0393B00010B40A /* sure_placeholder_error@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 88E8855B1E0393B00010B40A /* sure_placeholder_error@3x.png */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXFileReference section */
22 | 8831A8BB1DFFA2410039B63A /* SureWebViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SureWebViewController.app; sourceTree = BUILT_PRODUCTS_DIR; };
23 | 8831A8BF1DFFA2410039B63A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
24 | 8831A8C11DFFA2410039B63A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
25 | 8831A8C21DFFA2410039B63A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
26 | 8831A8C41DFFA2410039B63A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
27 | 8831A8C51DFFA2410039B63A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
28 | 8831A8C81DFFA2410039B63A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
29 | 8831A8CA1DFFA2410039B63A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
30 | 8831A8CD1DFFA2410039B63A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
31 | 8831A8CF1DFFA2410039B63A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
32 | 8831A8D51DFFA3180039B63A /* SureWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SureWebViewController.h; sourceTree = ""; };
33 | 8831A8D61DFFA3180039B63A /* SureWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SureWebViewController.m; sourceTree = ""; };
34 | 88E8855A1E0393B00010B40A /* sure_placeholder_error@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "sure_placeholder_error@2x.png"; sourceTree = ""; };
35 | 88E8855B1E0393B00010B40A /* sure_placeholder_error@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "sure_placeholder_error@3x.png"; sourceTree = ""; };
36 | /* End PBXFileReference section */
37 |
38 | /* Begin PBXFrameworksBuildPhase section */
39 | 8831A8B81DFFA2410039B63A /* Frameworks */ = {
40 | isa = PBXFrameworksBuildPhase;
41 | buildActionMask = 2147483647;
42 | files = (
43 | );
44 | runOnlyForDeploymentPostprocessing = 0;
45 | };
46 | /* End PBXFrameworksBuildPhase section */
47 |
48 | /* Begin PBXGroup section */
49 | 8831A8B21DFFA2410039B63A = {
50 | isa = PBXGroup;
51 | children = (
52 | 8831A8BD1DFFA2410039B63A /* SureWebViewController */,
53 | 8831A8BC1DFFA2410039B63A /* Products */,
54 | );
55 | sourceTree = "";
56 | };
57 | 8831A8BC1DFFA2410039B63A /* Products */ = {
58 | isa = PBXGroup;
59 | children = (
60 | 8831A8BB1DFFA2410039B63A /* SureWebViewController.app */,
61 | );
62 | name = Products;
63 | sourceTree = "";
64 | };
65 | 8831A8BD1DFFA2410039B63A /* SureWebViewController */ = {
66 | isa = PBXGroup;
67 | children = (
68 | 8831A8C11DFFA2410039B63A /* AppDelegate.h */,
69 | 8831A8C21DFFA2410039B63A /* AppDelegate.m */,
70 | 8831A8C41DFFA2410039B63A /* ViewController.h */,
71 | 8831A8C51DFFA2410039B63A /* ViewController.m */,
72 | 8831A8D51DFFA3180039B63A /* SureWebViewController.h */,
73 | 8831A8D61DFFA3180039B63A /* SureWebViewController.m */,
74 | 88E8855A1E0393B00010B40A /* sure_placeholder_error@2x.png */,
75 | 88E8855B1E0393B00010B40A /* sure_placeholder_error@3x.png */,
76 | 8831A8C71DFFA2410039B63A /* Main.storyboard */,
77 | 8831A8CA1DFFA2410039B63A /* Assets.xcassets */,
78 | 8831A8CC1DFFA2410039B63A /* LaunchScreen.storyboard */,
79 | 8831A8CF1DFFA2410039B63A /* Info.plist */,
80 | 8831A8BE1DFFA2410039B63A /* Supporting Files */,
81 | );
82 | path = SureWebViewController;
83 | sourceTree = "";
84 | };
85 | 8831A8BE1DFFA2410039B63A /* Supporting Files */ = {
86 | isa = PBXGroup;
87 | children = (
88 | 8831A8BF1DFFA2410039B63A /* main.m */,
89 | );
90 | name = "Supporting Files";
91 | sourceTree = "";
92 | };
93 | /* End PBXGroup section */
94 |
95 | /* Begin PBXNativeTarget section */
96 | 8831A8BA1DFFA2410039B63A /* SureWebViewController */ = {
97 | isa = PBXNativeTarget;
98 | buildConfigurationList = 8831A8D21DFFA2410039B63A /* Build configuration list for PBXNativeTarget "SureWebViewController" */;
99 | buildPhases = (
100 | 8831A8B71DFFA2410039B63A /* Sources */,
101 | 8831A8B81DFFA2410039B63A /* Frameworks */,
102 | 8831A8B91DFFA2410039B63A /* Resources */,
103 | );
104 | buildRules = (
105 | );
106 | dependencies = (
107 | );
108 | name = SureWebViewController;
109 | productName = SureWebViewController;
110 | productReference = 8831A8BB1DFFA2410039B63A /* SureWebViewController.app */;
111 | productType = "com.apple.product-type.application";
112 | };
113 | /* End PBXNativeTarget section */
114 |
115 | /* Begin PBXProject section */
116 | 8831A8B31DFFA2410039B63A /* Project object */ = {
117 | isa = PBXProject;
118 | attributes = {
119 | LastUpgradeCheck = 0800;
120 | ORGANIZATIONNAME = "刘硕";
121 | TargetAttributes = {
122 | 8831A8BA1DFFA2410039B63A = {
123 | CreatedOnToolsVersion = 8.0;
124 | DevelopmentTeam = UH3CV2MYJP;
125 | ProvisioningStyle = Automatic;
126 | };
127 | };
128 | };
129 | buildConfigurationList = 8831A8B61DFFA2410039B63A /* Build configuration list for PBXProject "SureWebViewController" */;
130 | compatibilityVersion = "Xcode 3.2";
131 | developmentRegion = English;
132 | hasScannedForEncodings = 0;
133 | knownRegions = (
134 | en,
135 | Base,
136 | );
137 | mainGroup = 8831A8B21DFFA2410039B63A;
138 | productRefGroup = 8831A8BC1DFFA2410039B63A /* Products */;
139 | projectDirPath = "";
140 | projectRoot = "";
141 | targets = (
142 | 8831A8BA1DFFA2410039B63A /* SureWebViewController */,
143 | );
144 | };
145 | /* End PBXProject section */
146 |
147 | /* Begin PBXResourcesBuildPhase section */
148 | 8831A8B91DFFA2410039B63A /* Resources */ = {
149 | isa = PBXResourcesBuildPhase;
150 | buildActionMask = 2147483647;
151 | files = (
152 | 88E8855C1E0393B00010B40A /* sure_placeholder_error@2x.png in Resources */,
153 | 8831A8CE1DFFA2410039B63A /* LaunchScreen.storyboard in Resources */,
154 | 88E8855D1E0393B00010B40A /* sure_placeholder_error@3x.png in Resources */,
155 | 8831A8CB1DFFA2410039B63A /* Assets.xcassets in Resources */,
156 | 8831A8C91DFFA2410039B63A /* Main.storyboard in Resources */,
157 | );
158 | runOnlyForDeploymentPostprocessing = 0;
159 | };
160 | /* End PBXResourcesBuildPhase section */
161 |
162 | /* Begin PBXSourcesBuildPhase section */
163 | 8831A8B71DFFA2410039B63A /* Sources */ = {
164 | isa = PBXSourcesBuildPhase;
165 | buildActionMask = 2147483647;
166 | files = (
167 | 8831A8C61DFFA2410039B63A /* ViewController.m in Sources */,
168 | 8831A8C31DFFA2410039B63A /* AppDelegate.m in Sources */,
169 | 8831A8D71DFFA3180039B63A /* SureWebViewController.m in Sources */,
170 | 8831A8C01DFFA2410039B63A /* main.m in Sources */,
171 | );
172 | runOnlyForDeploymentPostprocessing = 0;
173 | };
174 | /* End PBXSourcesBuildPhase section */
175 |
176 | /* Begin PBXVariantGroup section */
177 | 8831A8C71DFFA2410039B63A /* Main.storyboard */ = {
178 | isa = PBXVariantGroup;
179 | children = (
180 | 8831A8C81DFFA2410039B63A /* Base */,
181 | );
182 | name = Main.storyboard;
183 | sourceTree = "";
184 | };
185 | 8831A8CC1DFFA2410039B63A /* LaunchScreen.storyboard */ = {
186 | isa = PBXVariantGroup;
187 | children = (
188 | 8831A8CD1DFFA2410039B63A /* Base */,
189 | );
190 | name = LaunchScreen.storyboard;
191 | sourceTree = "";
192 | };
193 | /* End PBXVariantGroup section */
194 |
195 | /* Begin XCBuildConfiguration section */
196 | 8831A8D01DFFA2410039B63A /* Debug */ = {
197 | isa = XCBuildConfiguration;
198 | buildSettings = {
199 | ALWAYS_SEARCH_USER_PATHS = NO;
200 | CLANG_ANALYZER_NONNULL = YES;
201 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
202 | CLANG_CXX_LIBRARY = "libc++";
203 | CLANG_ENABLE_MODULES = YES;
204 | CLANG_ENABLE_OBJC_ARC = YES;
205 | CLANG_WARN_BOOL_CONVERSION = YES;
206 | CLANG_WARN_CONSTANT_CONVERSION = YES;
207 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
208 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
209 | CLANG_WARN_EMPTY_BODY = YES;
210 | CLANG_WARN_ENUM_CONVERSION = YES;
211 | CLANG_WARN_INFINITE_RECURSION = YES;
212 | CLANG_WARN_INT_CONVERSION = YES;
213 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
214 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
215 | CLANG_WARN_UNREACHABLE_CODE = YES;
216 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
217 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
218 | COPY_PHASE_STRIP = NO;
219 | DEBUG_INFORMATION_FORMAT = dwarf;
220 | ENABLE_STRICT_OBJC_MSGSEND = YES;
221 | ENABLE_TESTABILITY = YES;
222 | GCC_C_LANGUAGE_STANDARD = gnu99;
223 | GCC_DYNAMIC_NO_PIC = NO;
224 | GCC_NO_COMMON_BLOCKS = YES;
225 | GCC_OPTIMIZATION_LEVEL = 0;
226 | GCC_PREPROCESSOR_DEFINITIONS = (
227 | "DEBUG=1",
228 | "$(inherited)",
229 | );
230 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
231 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
232 | GCC_WARN_UNDECLARED_SELECTOR = YES;
233 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
234 | GCC_WARN_UNUSED_FUNCTION = YES;
235 | GCC_WARN_UNUSED_VARIABLE = YES;
236 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
237 | MTL_ENABLE_DEBUG_INFO = YES;
238 | ONLY_ACTIVE_ARCH = YES;
239 | SDKROOT = iphoneos;
240 | };
241 | name = Debug;
242 | };
243 | 8831A8D11DFFA2410039B63A /* Release */ = {
244 | isa = XCBuildConfiguration;
245 | buildSettings = {
246 | ALWAYS_SEARCH_USER_PATHS = NO;
247 | CLANG_ANALYZER_NONNULL = YES;
248 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
249 | CLANG_CXX_LIBRARY = "libc++";
250 | CLANG_ENABLE_MODULES = YES;
251 | CLANG_ENABLE_OBJC_ARC = YES;
252 | CLANG_WARN_BOOL_CONVERSION = YES;
253 | CLANG_WARN_CONSTANT_CONVERSION = YES;
254 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
255 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
256 | CLANG_WARN_EMPTY_BODY = YES;
257 | CLANG_WARN_ENUM_CONVERSION = YES;
258 | CLANG_WARN_INFINITE_RECURSION = YES;
259 | CLANG_WARN_INT_CONVERSION = YES;
260 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
261 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
262 | CLANG_WARN_UNREACHABLE_CODE = YES;
263 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
264 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
265 | COPY_PHASE_STRIP = NO;
266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
267 | ENABLE_NS_ASSERTIONS = NO;
268 | ENABLE_STRICT_OBJC_MSGSEND = YES;
269 | GCC_C_LANGUAGE_STANDARD = gnu99;
270 | GCC_NO_COMMON_BLOCKS = YES;
271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
273 | GCC_WARN_UNDECLARED_SELECTOR = YES;
274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
275 | GCC_WARN_UNUSED_FUNCTION = YES;
276 | GCC_WARN_UNUSED_VARIABLE = YES;
277 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
278 | MTL_ENABLE_DEBUG_INFO = NO;
279 | SDKROOT = iphoneos;
280 | VALIDATE_PRODUCT = YES;
281 | };
282 | name = Release;
283 | };
284 | 8831A8D31DFFA2410039B63A /* Debug */ = {
285 | isa = XCBuildConfiguration;
286 | buildSettings = {
287 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
288 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
289 | DEVELOPMENT_TEAM = UH3CV2MYJP;
290 | INFOPLIST_FILE = SureWebViewController/Info.plist;
291 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
292 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
293 | PRODUCT_BUNDLE_IDENTIFIER = com.sure.SureWebViewController;
294 | PRODUCT_NAME = "$(TARGET_NAME)";
295 | };
296 | name = Debug;
297 | };
298 | 8831A8D41DFFA2410039B63A /* Release */ = {
299 | isa = XCBuildConfiguration;
300 | buildSettings = {
301 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
302 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
303 | DEVELOPMENT_TEAM = UH3CV2MYJP;
304 | INFOPLIST_FILE = SureWebViewController/Info.plist;
305 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
306 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
307 | PRODUCT_BUNDLE_IDENTIFIER = com.sure.SureWebViewController;
308 | PRODUCT_NAME = "$(TARGET_NAME)";
309 | };
310 | name = Release;
311 | };
312 | /* End XCBuildConfiguration section */
313 |
314 | /* Begin XCConfigurationList section */
315 | 8831A8B61DFFA2410039B63A /* Build configuration list for PBXProject "SureWebViewController" */ = {
316 | isa = XCConfigurationList;
317 | buildConfigurations = (
318 | 8831A8D01DFFA2410039B63A /* Debug */,
319 | 8831A8D11DFFA2410039B63A /* Release */,
320 | );
321 | defaultConfigurationIsVisible = 0;
322 | defaultConfigurationName = Release;
323 | };
324 | 8831A8D21DFFA2410039B63A /* Build configuration list for PBXNativeTarget "SureWebViewController" */ = {
325 | isa = XCConfigurationList;
326 | buildConfigurations = (
327 | 8831A8D31DFFA2410039B63A /* Debug */,
328 | 8831A8D41DFFA2410039B63A /* Release */,
329 | );
330 | defaultConfigurationIsVisible = 0;
331 | defaultConfigurationName = Release;
332 | };
333 | /* End XCConfigurationList section */
334 | };
335 | rootObject = 8831A8B31DFFA2410039B63A /* Project object */;
336 | }
337 |
--------------------------------------------------------------------------------