White Screen on Simulator Iphone Xcode

White Screen on Simulator Iphone Xcode

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

@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

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

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.