WKWebView does not display public Weebly HTML page

2019-07-30 12:56发布

问题:

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.