2015-11-06 440 views
0

我看了這個視頻在YouTube上: Xcode中如何創建iOS應用程序網頁視圖白色屏幕上模擬iPhone的Xcode

我跟着視頻,但如果我在模擬器上運行我的應用程序,只有我看到白色的屏幕。

enter image description here

這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:@"http://website.com"]; NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL]; myWebView.scalesPageToFit = YES; [myWebView loadRequest:myRequest]; 

} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 

你能幫我解決這個錯誤?

+3

顯示代碼。你的VC上有沒有'UIelement'?還分享你的故事板的截圖。 – NSNoob

+0

請顯示驗證碼。 –

+0

添加我的代碼,等着你,謝謝 – MeshariSan

回答

0

這ViewController.m

// 
// ViewController.m 
// 

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 


    NSURL *myURL = [NSURL URLWithString:@"http://website.com"]; NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL]; myWebView.scalesPageToFit = YES; [myWebView loadRequest:myRequest]; 

} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 
0

您必須在創建後實際加載的要求!

NSURL *url = [NSURL URLWithString:@"http://yoururl.com"]; 
NSURLRequest *request = [NSURLRequest requestWithURL:url]; 
[self.webView loadRequest:request];