Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

white screen on simulator iphone Xcode

Writer 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.

enter image description here

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.
}
@end

Can you get me fix this error?

3

2 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];

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy