2013-04-11 88 views
1

Xcode的新手,我的代碼在這裏出了什麼問題?'NSURLRequest'沒有可見的@interface聲明選擇器'initwithURL:'

[super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a nib. 
Webview.userInteractionEnabled = TRUE; 
[UIWebView loadRequest: [[[NSURLRequest alloc] initwithURL:[[NSURL alloc] initWithString:@"http://www.reddit.com/r/Diecast/"]]]; 
[super viewDidLoad]; 

請幫忙,如果我做錯了什麼,請糾正我!我正在嘗試爲該特定頁面創建瀏覽器,以便人們可以打開圖片並瀏覽頁面。

謝謝!

回答

2

檢查你的資本上-initWithURL:

此外,您還需要調用loadRequest:您的網頁視圖實例,而不是通過類UIWebView

NSURL *url = [[NSURL alloc] initWithString:@"http://www.reddit.com/r/Diecast/"]; 
NSURLRequest *request = [NSURLRequest alloc] initWithURL:url]; 
[Webview loadRequest:request]; 
+0

+1解釋變化(從簡單地看着修改後的代碼中不明顯) – borrrden 2013-04-11 01:16:12

+0

哇,它工作得很好,謝謝一大堆! – user2268353 2013-04-11 01:40:12

0

試試這個

[super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a nib. 
Webview.userInteractionEnabled = YES; 
[Webview loadRequest: [[[NSURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:@"http://www.reddit.com/r/Diecast/"]]]; 
+0

沒有工作,謝謝反正! – user2268353 2013-04-11 01:38:30

相關問題