iOS7 UIWebView - 在导航栏下方设置内容起始位置 [英] iOS7 UIWebView - Set content starting position below navigation bar

查看:31
本文介绍了iOS7 UIWebView - 在导航栏下方设置内容起始位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Storyboard (IB) 中设计了一个 UIViewController,如下所示:

I have a UIViewController designed in a Storyboard (IB) as follows :

  • UIWebView 被拉伸以填满整个画布
  • UIWebView 具有 AutoLayout 约束,可将所有 4 个边固定到父视图的边缘
  • UIViewController 已勾选所有扩展边缘"选项,因此 UIWebView 位于导航栏下方
  • UIViewController 未勾选调整滚动视图插图"
  • UIViewController 在 UINavigationController 中加载

我希望在加载 VC 时将 UIWebView 内容的顶部直接定位在导航栏下方,并允许用户在导航栏下方的屏幕上滚动内容(与 Dropbox应用程序在查看 PDF 时工作).我已经尝试过各种尝试,包括使用:

What I want to happen when the VC loads is for the top of the UIWebView content to be positioned immediately below the navigation bar, and allow the user to scroll the content up the screen under the navigation bar (same as how the Dropbox app works when viewing PDFs). I have tried various attempts at this including using :

[webView.scrollView setContentInset:UIEdgeInsetsMake(64, 0, 0, 0)];
[webView.scrollView setScrollIndicatorInsets:UIEdgeInsetsMake(64, 0, 0, 0)];
[webView.scrollView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];

但我无法让它工作 - 我只是从屏幕顶部开始,导航栏下方的内容结束.我想知道 AutoLayout 是否阻止了这项工作?

but I can't get it working - I just end up with the content starting at the top of the screen, underneath the navigation bar. I'm wondering if AutoLayout is preventing this working?

推荐答案

我遇到了同样的问题并修复了它.解决方法很简单:

I had the same issue and fixed it. The solution is pretty simple:

转到情节提要,选择包含您的 UIWebView 的视图控制器并打开 Attributes Inspector.在这里,您会看到标题Extend Edges",只需取消选中Under Top Bars"框,我就可以了!

Go to the storyboard, select the view controller which contains your UIWebView and open the Attributes Inspector. Here, you'll see the title "Extend Edges", just uncheck the box "Under Top Bars" and I will work !

这篇关于iOS7 UIWebView - 在导航栏下方设置内容起始位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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