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,但服务器证书似乎是自签名的.

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

来自法国的欢呼声

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...