ios – Xcode 7 UIWebView不加载网址

我在我的应用程序中使用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,但服务器证书似乎是自签名的.

如果此解决方法适合您,请告诉我

来自法国的欢呼声

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...