WKWebView不显示公共Weebly HTML页面

时间:2017-02-10 00:54:52

标签: ios wkwebview cfnetwork

日志在应用启动时显示以下内容:

CFNetwork internal error (0xc01a:/BuildRoot/Library/Caches/com.apple.xbs/Sources/CFNetwork_Sim/CFNetwork-808.2.16/ProjectRuntime/CFNetworkInternal.h:481)

我以编程方式添加WKWebView以显示网站上声明的隐私政策:

- (void) show_Website_Address: (NSString *)theAddress {

    CGRect newFrame = self.view.frame;
    newFrame = CGRectMake(self.view.frame.origin.x + 75, newFrame.origin.y, self.view.frame.size.width - 150, newFrame.size.height);

    self.back_Button.hidden = true;
    UIButton *tempButton = [[UIButton alloc] initWithFrame: self.back_Button.frame];
    [tempButton addTarget:self action:@selector(pressed_To_Hide_Website:) forControlEvents:UIControlEventTouchUpInside];
    [tempButton setTitle:@"Info" forState:UIControlStateNormal];
    tempButton.titleLabel.font = [UIFont systemFontOfSize:12];
    [tempButton setTitleColor: [UIColor blueColor] forState:UIControlStateNormal];
    [self.view addSubview: tempButton];

    WKWebView *tempWebview = [[WKWebView alloc]initWithFrame:newFrame];
    NSURL *url = [NSURL URLWithString:theAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    self.webView = tempWebview;
    [tempWebview loadRequest:requestObj];
    self.webView.UIDelegate = (id<WKUIDelegate>)self;
    self.webView.navigationDelegate = (id<WKNavigationDelegate>)self;

    self.webView.layer.borderColor = [[UIColor blueColor] CGColor];
    self.webView.layer.borderWidth = 1.0f;
    [self.view addSubview: self.webView];
}

WKWebView显示空白,可滚动的白色HTML页面,不会加载目标网站地址。传递的NSString theAddress与在Weebly服务器上运行的https://地址相同。

NSAppTransportSecurity有:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>

任何想法在浏览这个谷歌搜索后得到赞赏。它似乎比在Stackoverflow上找到here的未应答的购物车/网站查询更简单的WKWebView加载问题。

使用Xcode Simulator(10.2)和Device 6s - 都表现出相同的行为。

0 个答案:

没有答案