2010-07-22 68 views
12

哪裏可以找到關於如何創建和使用UIWebView的簡單可編譯示例?iPhone/iPad WebView示例

任何非界面生成器示例?

+1

乾脆放棄學習的Objective-C和Interface Builder。這是一個苛刻的建議,但如果你想寫一個iPhone應用程序,這是不可避免的。將其視爲學習新語言和新視角的一種方式。 – Yuji 2010-07-22 03:29:24

回答

33
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 
[webView setDelegate:self]; 

NSString *urlAddress = @"http://www.google.com/"; 
NSURL *url = [NSURL URLWithString:urlAddress]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
[webView loadRequest:requestObj]; 

[self.view addSubview:webView]; 
1
WebView - Add the Delegate 

@property (strong, nonatomic) IBOutlet UIWebView *WebView; 

NSString *fullURL = @"http://facebook.com/"; 
NSURL *url = [NSURL URLWithString:fullURL]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
[_WebView loadRequest:requestObj];