Ios – UIWebView loading but not displaying website (XCode 4, iOS SDK 4.3)

iosiphoneuiwebview

i'm going to write an app including an UIWebView. So first I wanted to try it out by just simply loading an URL.

  • Created the UIWebView in Interface Builder
  • Hooked up to the code

    @property(nonatomic,retain) IBOutlet UIWebView *webView;

viewDidLoad:

- (void)viewDidLoad {
[super viewDidLoad];
if(!webView)
{
    webView = [[UIWebView alloc]init];
}

webView.delegate = self;

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]]; }

also I implemented the didFailLoadWithError and webViewDidFinishLoad delegate methods.
webViewDidFinishLoad is called and indicating that HTML has been loaded.

Problem is: Even though webViewDidFinishLoad is called, the UIWebView doesn't display the website. It's only showing white color. The scroll bars right and at the bottom are shown when the UIWebView is touched and dragged but not content is visible. Nowhere found anything. Seems quite strange..

EDIT
This screenshot shows the connections of the xib:

Connections

Best Answer

If you hooked everything up in Interface Builder correctly, the following lines should not be needed:

if(!webView)
{
    webView = [[UIWebView alloc]init];
}

webView.delegate = self;

Try removing them and see what happens. Also, put an NSLog(...) in the webView:didFailLoadWithError: callback and see if it is output.

Related Topic