UIWebView显示网页失败
来源:互联网 发布:淘宝的kindle不能注册 编辑:程序博客网 时间:2024/05/17 16:55
编译器版本:XCode 8.3.1
IOS版本:10.2
使用UIWebView显示网页失败,提示:App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
新特性要求App内访问网络请求,要采用 HTTPS 协议,如果网页支持https协议,则改为https访问,如果不支持https则使用以下方法:
1.在Info.plist右键添加一行Key为:App Transport Security Settings,Type为:Dictionary
2.在App Transport Security Settings下添加字Key为:Allow Arbitrary Loads,Type为:Boolean,Value为:YES
重新运行就可以加载成功了。
//// WebViewController.m// 网页显示界面//// Created by dcr on 2017/3/11.// Copyright © 2017年. All rights reserved.//#import "WebViewController.h"@interface WebViewController ()<UIWebViewDelegate>@property (weak, nonatomic) IBOutlet UIWebView *webView;@end@implementation WebViewController- (instancetype)initWithUrl:(NSString *)url{ self = [super init]; if(self){ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; [_webView loadRequest:request]; } return self;}- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. _webView.frame = self.view.frame; _webView.delegate = self; NSLog(@"url = %@", _url); if(_url != nil){ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_url]]; [_webView loadRequest:request]; }}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}//UIWebViewDelegate- (void)webViewDidStartLoad:(UIWebView *)webView{ NSLog(@"webViewDidStartLoad");}- (void)webViewDidFinishLoad:(UIWebView *)webView{ NSLog(@"webViewDidFinishLoad");}- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{ NSLog(@"didFailLoadWithError");}/*#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
0 0
- UIWebView显示网页失败
- UIWebView显示本地网页
- UIwebview显示网页内容
- UIWebView不能显示网页
- UIWebView 显示正在加载网页
- 网页显示UIWebView(一)
- UIWebView显示网页没有置顶显示
- iphone用UIWebView来显示网页
- cocos2d-x加载UIWebView显示网页
- 利用UIWebView显示pdf文件,网页等等
- 解决ipad uiwebview显示网页超过屏幕宽度
- UIWebView 显示
- 【IOS 开发】UIWebView 加载本地文件,多层的网页目录结构失败分析和解决,以及demo
- UIWebView之hack网页
- UIWebView网页视图
- 使用UIWebView加载网页
- UIWebView 加载网页
- UIWebView网页视图
- 微信支付JSAPI支付
- windows下yeoman安装
- autoencode
- 兼容其他不支持placeholder的浏览器(超强的让IE下支持placeholder的属性插件)
- 华为云linux搭建tomcat
- UIWebView显示网页失败
- ACM-红与黑
- 虚拟机下CentOS7开启SSH连接
- plat_button驱动实例
- Spring的AOP配置
- 观复嘟嘟观古今
- centos下使用源码安装redis及php-redis
- tomcat服务器优化方案
- checkbox兼容主流浏览器的自定义样式