在iPad上的UIWebView大小
问题描述:
我在iPad上使用UIWebView,我通过下面的代码进行初始化。问题是,视图不会显示在状态栏下方的页面顶部,但还有另一个44像素的空间(填充黑色) - 对于导航栏,我不想显示。任何提示如何使UIWebView在没有44px空间的情况下显示?在iPad上的UIWebView大小
非常感谢,
BR
斯登
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect rectApp = [[UIScreen mainScreen] applicationFrame];
self.webView = [[[UIWebView alloc] initWithFrame:rectApp] autorelease];
self.webView.backgroundColor = [UIColor whiteColor];
self.webView.scalesPageToFit = YES;
self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.webView.delegate = self;
[self.view addSubview: self.webView];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.test.com/shop/index.php"]]];
}
答
的问题是,该视图的坐标系统,您要添加它是不是窗口的坐标系;该视图已经为状态栏进行了调整。
变化这样说:
CGRect rectApp = [[UIScreen mainScreen] applicationFrame];
rectApp.origin = CGPointZero;
或者更好的是,使用self.view.bounds
,因为self.view
大概是指反正填充应用程序的窗口视图。
答
我喜欢托尼的回答。当我碰到这个问题时,我用通用view.frame = self.view.bounds,在你的代码中这样写:
self.webView.frame = self.view.bounds;
谢谢!它完美的作品。 – STeN 2010-07-09 03:22:46