【问题标题】:UIWebView on iPad sizeiPad 尺寸上的 UIWebView
【发布时间】:2010-07-07 12:52:11
【问题描述】:

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

非常感谢,

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

【问题讨论】:

    标签: cocoa-touch ipad uiwebview


    【解决方案1】:

    问题是你添加它的视图的坐标系不是窗口的坐标系;视图已经针对状态栏进行了调整。

    这样改:

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

    或者更好的是,使用self.view.bounds,因为self.view 可能指的是无论如何填充应用程序窗口的视图。

    【讨论】:

      【解决方案2】:

      我喜欢托尼的回答。当我遇到这个问题时,我使用了通用 view.frame = self.view.bounds,在你的代码中会这样写:

      self.webView.frame = self.view.bounds;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-02-14
        • 1970-01-01
        • 1970-01-01
        • 2015-12-10
        • 1970-01-01
        • 2014-03-17
        • 2014-03-16
        相关资源
        最近更新 更多