我想你已經爲webview.That固定框架,同時實施定向CHAGE
試試這不會幫助:
使用此代碼用於顯示網頁view.Change堆棧流量網址與您的網址;
contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.view = contentView;
self.view.autoresizesSubviews = YES;
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webFrame.origin.y -= 20.0;
webView = [[UIWebView alloc] initWithFrame:webFrame];
[contentView addSubview:webView];
webView.scalesPageToFit = YES;
webView.autoresizesSubviews = YES;
webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
[webView setBackgroundColor:[UIColor clearColor]];
NSString *urlAddress = @"https://www.stackoverflow.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
webView.delegate =self;
[webView release];
爲了支持方向
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation
{
return YES;
}
對於Web視圖變化與方向
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if(fromInterfaceOrientation == UIInterfaceOrientationPortrait){
[webView stringByEvaluatingJavaScriptFromString:@"rotate(0)"];
}
else{
[webView stringByEvaluatingJavaScriptFromString:@"rotate(1)"];
}
}
希望上述將滿足您的要求。 一切順利。
謝謝。我想在我的webview中顯示工具欄?我怎麼能做到這一點?我無法在我的webview中看到工具欄。 – Pugal 2010-02-25 12:51:21
@pugal插入標籤欄作爲子視圖... [self.view insertSubview:tBar belowSubview:contentView]; 將tBar更改爲您已使用的工具欄。 – Warrior 2010-02-25 12:57:07