WKWebView does not display public Weebly HTML page

烂漫一生 提交于 2019-12-11 04:45:08

问题


Log shows the following upon app launch:

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

I add a WKWebView programmatically to show a privacy policy stated on a website:

- (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];
}

The WKWebView displays a blank, scrollable, white HTML page and does not load the target website address. The passed NSString theAddress is identical to https:// address that works on a Weebly server.

The NSAppTransportSecurity has:

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

Any ideas appreciated after time spent on this googling. It appears to be a simpler WKWebView loading problem than the unanswered cart/website query found here on Stackoverflow.

Using Xcode Simulator (10.2) and Device 6s - both show same behaviour.

来源:https://stackoverflow.com/questions/42149734/wkwebview-does-not-display-public-weebly-html-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!