//
|
// AboutOurViewController.m
|
// PapayaPlayerDaqo
|
//
|
// Created by weikou on 15/8/4.
|
// Copyright (c) 2015年 wgj. All rights reserved.
|
//
|
|
#import "SettingWebView.h"
|
#import "dsbridge.h"
|
#import "JSAPI.h"
|
|
@interface SettingWebView ()
|
|
@property (nonatomic, nullable, strong) DWKWebView *webView;
|
|
@end
|
|
@implementation SettingWebView
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
self.title = _webTitle;
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
[button setImage:[[UIImage imageNamed:@"详情页面返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
|
[button addTarget:self action:@selector(back:)
|
forControlEvents:UIControlEventTouchUpInside];
|
button.frame = CGRectMake(0, 0, 32, 32);
|
UIBarButtonItem *iconBarItem=[[UIBarButtonItem alloc] initWithCustomView:button];
|
self.navigationItem.leftBarButtonItem = iconBarItem;
|
//设置使用模态跳转的返回按钮
|
if(_ispresent){
|
//隐藏状态栏
|
[[UIApplication sharedApplication] setStatusBarHidden:YES];
|
//添加返回按钮
|
CGFloat height = 15;
|
if (KIsiPhoneX) {
|
height = 35;
|
}
|
UIButton *backButton=[[UIButton alloc] initWithFrame:CGRectMake(15, height, 32, 32)];
|
[backButton setImage:[UIImage imageNamed:@"取消登录"] forState:UIControlStateNormal];
|
[backButton addTarget:self action:@selector(presentBack) forControlEvents:UIControlEventTouchUpInside];
|
[self.view addSubview:backButton];
|
}
|
CGFloat height = 64;
|
if (KIsiPhoneX) {
|
height = 84;
|
}
|
|
// WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH - height)];
|
[self.view addSubview: self.webView];
|
[self.webView addJavascriptObject:[[JSAPI alloc] init] namespace:@"yestv"];
|
NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:_requestURL]];
|
[_webView loadRequest:request];
|
// Do any additional setup after loading the view from its nib.
|
}
|
|
|
- (DWKWebView *)webView {
|
if (!_webView) {
|
// 0.网页配置对象
|
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
|
// 1.原生与JS交互管理
|
WKUserContentController *userContentController = [[WKUserContentController alloc] init];
|
|
// 添加
|
config.userContentController = userContentController;
|
|
// 3.WKWebview设置
|
WKPreferences *prefer = [[WKPreferences alloc] init];
|
//设置是否支持javaScript 默认是支持的
|
prefer.javaScriptEnabled = YES;
|
// // 在iOS上默认为NO,表示是否允许不经过用户交互由javaScript自动打开窗口
|
prefer.javaScriptCanOpenWindowsAutomatically = YES;
|
// 添加
|
config.preferences = prefer;
|
config.preferences.minimumFontSize = 0.0f;
|
// 是使用h5的视频播放器在线播放, 还是使用原生播放器全屏播放
|
config.allowsInlineMediaPlayback = YES;
|
//设置视频是否需要用户手动播放 设置为NO则会允许自动播放
|
config.mediaTypesRequiringUserActionForPlayback = YES;
|
//设置是否允许画中画技术 在特定设备上有效
|
config.allowsPictureInPictureMediaPlayback = YES;
|
//设置请求的User-Agent信息中应用程序名称 iOS9后可用
|
config.applicationNameForUserAgent = @"ChinaDailyForiPad";
|
|
config.suppressesIncrementalRendering = YES;
|
|
CGFloat height = 64;
|
if (KIsiPhoneX) {
|
height = 84;
|
}
|
|
_webView = [[DWKWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH - height) configuration:config];
|
|
_webView.DSUIDelegate = self;
|
_webView.navigationDelegate = self;
|
|
// 是否允许手势左滑返回上一级, 类似导航控制的左滑返回
|
_webView.allowsBackForwardNavigationGestures = YES;
|
//可返回的页面列表, 存储已打开过的网页
|
//WKBackForwardList * backForwardList = [_webView backForwardList];
|
}
|
return _webView;
|
}
|
|
-(void)presentBack{
|
[self dismissViewControllerAnimated:YES completion:^{
|
//状态栏重现
|
[[UIApplication sharedApplication] setStatusBarHidden:NO];
|
}];
|
}
|
|
- (void)didReceiveMemoryWarning {
|
[super didReceiveMemoryWarning];
|
// Dispose of any resources that can be recreated.
|
}
|
|
-(void)back:(id)sender{
|
if(_webView!=nil){
|
if([_webView canGoBack]){
|
[_webView goBack];
|
return;
|
}
|
}
|
[self.navigationController popViewControllerAnimated:YES];
|
}
|
|
/*
|
#pragma mark - Navigation
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
// Get the new view controller using [segue destinationViewController].
|
// Pass the selected object to the new view controller.
|
}
|
*/
|
|
@end
|