emj365
emj365

Reputation: 2314

UIWebView show blank to iOS dev beginner

I'm new for iOS develop. I tried to make a very simple app just show a UIWebView which display a web page:

ViewController.m:

#import "ViewController.h"

@implementation ViewController

@synthesize webView = _webView;

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSString *urlAddress = @"http://jsfiddle.net/emj365/qaQnF/embedded/result/";
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:requestObj];
}

...

ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {
    UIWebView * _webView;
}
@property (nonatomic, retain) IBOutlet UIWebView * webView;
@end

UIWebView show blank. What's wrong?

Upvotes: 1

Views: 1454

Answers (1)

Joris Kluivers
Joris Kluivers

Reputation: 12081

There are a few different things that could go wrong. A few options you should check:

  • Did you check to see if the outlet was actually connected to the webview in the xib?
  • Implement the UIWebView delegate and check for (networking) errors

Upvotes: 1

Related Questions