white screen on simulator iphone Xcode
Emily Wong
I watched this video on YouTube : Xcode How to Create a Webview for iOS Applications
I followed video but if I run my app on simulator, only I see white screen.
This ViewController.h
//
// ViewController.h
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{ IBOutlet UIWebView *myWebView;
}
@end
//// ViewController.m //
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad { [super viewDidLoad]; NSURL *myURL = [NSURL URLWithString:@""]; NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL]; myWebView.scalesPageToFit = YES; [myWebView loadRequest:myRequest];
}
- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.
}
@endCan you get me fix this error?
32 Answers
tHis ViewController.m
//
// ViewController.m
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad { [super viewDidLoad]; NSURL *myURL = [NSURL URLWithString:@""]; NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL]; myWebView.scalesPageToFit = YES; [myWebView loadRequest:myRequest];
}
- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.
}
@end You have to actually load the request after you create it!
NSURL *url = [NSURL URLWithString:@""];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];