- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
// CGRect webFrame = CGRectMake(0, 0, 320, 480);
UIWebView *webView = [[[UIWebView alloc] initWithFrame:webFrame] autorelease];
webView.backgroundColor = [UIColor whiteColor];
webView.scalesPageToFit = YES;
webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
webView.delegate = self;
[self.view addSubview: webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]]];
}
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
// CGRect webFrame = CGRectMake(0, 0, 320, 480);
UIWebView *webView = [[[UIWebView alloc] initWithFrame:webFrame] autorelease];
webView.backgroundColor = [UIColor whiteColor];
webView.scalesPageToFit = YES;
webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
webView.delegate = self;
[self.view addSubview: webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]]];
}
本文介绍如何在iOS应用中使用UIWebView加载指定网址的内容。通过设置UIWebView的frame、backgroundColor、scalesPageToFit等属性,并将其添加到视图中,实现网页的展示。

被折叠的 条评论
为什么被折叠?



