iPhone/iPad WebView 示例

13

我在哪里可以找到一个简单可编译的示例,演示如何创建和使用UIWebView?

是否有任何非界面构建器的示例?


1
放弃吧,学习Objective-C和Interface Builder。虽然这是一个严厉的建议,但如果你想编写iPhone应用程序,这是不可避免的。把它看作是学习一门新语言和新视角的方式。 - Yuji
2个回答

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接