iPad 尺寸上的 UIWebView [英] UIWebView on iPad size

查看:21
本文介绍了iPad 尺寸上的 UIWebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 iPad 上使用 UIWebView,我通过下面的代码对其进行初始化.问题是视图永远不会显示在状态栏下方的页面顶部,但是还有另一个 44px 空间(用黑色填充) - 用于导航栏,我不想显示.有什么提示可以让 UIWebView 在没有 44px 空间的情况下显示?

I am using the UIWebView on iPad, which I initialize by the code below. The problem is that the view is never displayed on the top of the page just under the Status bar, but there is another 44px space (filled with black color) - for Navigation Bar, which I do not want to display. Any hints how I can make the UIWebView be displayed without the 44px space?

非常感谢,

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"]]];
}

推荐答案

问题是你添加的view的坐标系不是window的坐标系;视图已经针对状态栏进行了调整.

The problem is that the coordinate system of the view you're adding it to isn't the coordinate system of the window; the view has already been adjusted for the status bar.

这样改:

CGRect rectApp = [[UIScreen mainScreen] applicationFrame];
rectApp.origin = CGPointZero;

或者更好的是,使用 self.view.bounds,因为 self.view 大概是指一个无论如何都会填充应用程序窗口的视图.

Or better yet, use self.view.bounds, since self.view presumably refers to a view that fills the application's window anyway.

这篇关于iPad 尺寸上的 UIWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆