[size=x-large]我们这次要显示出一个google首页[/size]
[img]http://dl.iteye.com/upload/attachment/349384/47301826-8b9c-378c-9955-2467a083e17c.png[/img]
[size=x-large]首先制作页面[/size]
[img]http://dl.iteye.com/upload/attachment/349386/0adce871-65b1-3820-92cb-7c605afc9e11.png[/img]
[size=x-large]将web view拖入视图中[/size]
[img]http://dl.iteye.com/upload/attachment/349394/6cc5e6de-5303-3e7d-b563-c7d177c14c78.png[/img]
[size=x-large]在.h文件中定义输出口[/size]
[size=x-large]对.xib文中的控制器和试图进行关联[/size]
[img]http://dl.iteye.com/upload/attachment/349398/59f11ca9-0f25-33cd-94eb-0cd4f82348cb.png[/img]
[size=x-large]在.m文件中完成代码[/size]
[size=x-large]这样,一个通过URL打开网页的程序就写完了。[/size]
[img]http://dl.iteye.com/upload/attachment/349384/47301826-8b9c-378c-9955-2467a083e17c.png[/img]
[size=x-large]首先制作页面[/size]
[img]http://dl.iteye.com/upload/attachment/349386/0adce871-65b1-3820-92cb-7c605afc9e11.png[/img]
[size=x-large]将web view拖入视图中[/size]
[img]http://dl.iteye.com/upload/attachment/349394/6cc5e6de-5303-3e7d-b563-c7d177c14c78.png[/img]
[size=x-large]在.h文件中定义输出口[/size]
@interface _1_17UIViewViewController : UIViewController {
UIWebView *webView;
}
@property (nonatomic,retain) IBOutlet UIWebView *webView;
[size=x-large]对.xib文中的控制器和试图进行关联[/size]
[img]http://dl.iteye.com/upload/attachment/349398/59f11ca9-0f25-33cd-94eb-0cd4f82348cb.png[/img]
[size=x-large]在.m文件中完成代码[/size]
@synthesize webView;
- (void)viewDidLoad {
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com.hk"]]];
[super viewDidLoad];
}
- (void)dealloc {
[webView release];
[super dealloc];
}
[size=x-large]这样,一个通过URL打开网页的程序就写完了。[/size]