1

我有一个UIWebView,我打开了一个网站,但有时没有调用委托方法,并且 UIWebView 显示一个空白页。但是当我使用 Safari 显示 HTML 代码时,UIWebView所有内容都已加载但未显示。有没有人遇到过类似的行为?

我没有什么特别的

NSURL *url = ...
NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.cordovaController.webView loadRequest:request];

- (void) webViewDidFinishLoad:(UIWebView*)theWebView
{
    NSLog(@"LOADING WEBSITE DONE");
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    NSLog(@"LOADING WEBSITE DONE WITH ERROR %@", [error description]);
}
4

3 回答 3

0

You will need to remember to connect (ctrl drag) the UIWebView object to the filesOwner button on the ViewController (the orange coloured button at the bottom) and select 'delegate'. You should find your code will get called now.

ctrl drag from UIWebView to files owner and select

I hope this helps. If it does, please mark this as correct +1 etc. Cheers Jim.

于 2013-07-29T13:37:24.090 回答
0

使用UIWebView委托方法打开 url

#pragma mark UIWebView Delegates -

    -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
    {
        if (navigationType == UIWebViewNavigationTypeLinkClicked) {

            [[UIApplication sharedApplication] openURL:[request URL]];
            return NO;  //only open in safari not in UIWebView
        }
        return YES;
    }

我希望它对你有用

于 2013-05-31T09:42:45.193 回答
0

你可能想看看:

UIWebview 缓慢加载安全页面

看起来 webview 可能正在努力管理一些用于连接到该页面的身份验证挑战。

于 2013-05-31T10:29:11.413 回答