代码如下:
在-(void)loadView方法中调用initWebView:[self initWebView];即可,效果如图:
[img]
[img]http://dl.iteye.com/upload/attachment/0078/7478/e3607797-b396-3a52-9d90-f3b728e7c2d5.png[/img]
[/img]
-(void)initWebView{
UIView *view = [[ UIView alloc] initWithFrame:[ UIScreen
mainScreen].applicationFrame] ;
self.view = view;
CGRect webFrame = CGRectMake(0.0,0.0,350.0,450.0);
//webFrame.origin.y+=25;
UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];
[webView setBackgroundColor:[UIColor whiteColor]];//设置北京为白色
webView.scalesPageToFit = YES;//适应屏幕大小
NSString * strURL = @"http://blog.youkuaiyun.com/m_changgong";
NSURL * url = [NSURL URLWithString:strURL];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
[self.view addSubview:webView];
[webView release];
}
在-(void)loadView方法中调用initWebView:[self initWebView];即可,效果如图:
[img]
[img]http://dl.iteye.com/upload/attachment/0078/7478/e3607797-b396-3a52-9d90-f3b728e7c2d5.png[/img]
[/img]