我正在尝试在一个干净的 UIViewController 中添加一个 UIWebView,它在我的 Storyboard 中嵌入了一个导航 Controller :
UIWebView *webView =[[UIWebView alloc] initWithFrame:self.view.bounds)];
webView.delegate = self;
[self.view addSubview:webView];
问题是,self.view.bounds.size.height 是 460,这似乎是包括导航栏在内的整个 View 的高度。我可以减去 self.view.frame.origin.y 的值(即 20)并获得所需的高度 440,但是是否有更常见的方法来执行此操作?
编辑
请在这里查看我的小代码示例:http://uploads.demaweb.dk/WebViewTest.zip
当您向下滚动到 UIWebView 的底部时,网站的最后一部分不会显示,因为 webView 太高了。
![在此处输入图片描述][1]
最佳答案
解决方案
在 UIWebView 中设置 autoresizingMask
解决了我的问题:
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
关于objective-c - 如何获取没有导航栏的 UIView 的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9331106/