我在我的应用程序中使用UIWebView,它在
Xcode4,5,6模拟器中都运行良好.但不适用于Xcode 7模拟器,我不知道为什么,模拟器中没有警告或错误,而且屏幕只显示空白页面.请帮我.谢谢.
#import "IndexViewController.h" @interface IndexViewController () @end @implementation IndexViewController - (void)viewDidLoad { [super viewDidLoad]; NSString *urlString = nil; NSString *languageCode = [[NSLocale preferredLanguages] objectAtIndex:0]; if ([languageCode isEqualToString:@"zh-Hans"]) { urlString = @"http://www.originoftime.net/index-cn"; }else if ([languageCode isEqualToString:@"zh-Hant"]) { urlString = @"http://www.originoftime.net/index-cn"; }else{ urlString = @"http://www.originoftime.net/index-en"; } NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]; NSURLRequest *urlrequest = [NSURLRequest requestWithURL:url]; [_Index loadRequest:urlrequest]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
解决方法
iOS9的Xcode 7现在强制您不使用HTTP调用,而是使用HTTPS调用.
这是AppTransportSecurity中增强的安全点.
试试这个:
>转到info.plist
>添加一个名为NSAppTransportSecurity的字典
>为此添加一个布尔属性,称为NSAllowsArbitraryLoads
>将其传递给TRUE
重新加载您的应用.
我建议你,如果Apple希望阻止HTTP(不安全)呼叫是有充分理由的. http://www.originoftime.net/index-cn有一个HTTPS,但服务器证书似乎是自签名的.
如果此解决方法适合您,请告诉我
来自法国的欢呼声
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。