[英]iOS 7 UIViewController (with navigation bar) doesn't inset UIScrollView
I've got a UINavigationController with a UIViewController showing a navigation bar. 我有一个带有UIViewController的UINavigationController,显示一个导航栏。
I've specifically set [self setAutomaticallyAdjustsScrollViewInsets:YES];
我特意设置了
[self setAutomaticallyAdjustsScrollViewInsets:YES];
, though this should be YES
by default anyway. ,尽管默认情况下这应该是
YES
。
I add a UIScrollView: 我添加了一个UIScrollView:
self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:self.scrollView];
However, the UIScrollView's contentInset is {0, 0, 0, 0}
, so I am wondering why it doesn't inherit the content inset from the view controller as the documentation states it would. 但是,UIScrollView的contentInset是
{0, 0, 0, 0}
0,0,0,0 {0, 0, 0, 0}
,所以我想知道它为什么不从视图控制器继承内容插入,因为文档声明它会。
If I add subviews to the scroll view and set their Y to be self.scrollView.contentInset.top
they don't appear below the navigation bar, which is what I am expected. 如果我将子视图添加到滚动视图并将其Y设置为
self.scrollView.contentInset.top
它们不会出现在导航栏下方,这正是我所期望的。
What am I doing wrong here? 我在这做错了什么? It works fine if you start out with a
UITableViewController
since it correctly inherits the contentInset
from the view controller. 如果你从
UITableViewController
开始,它工作正常,因为它正确地从视图控制器继承contentInset
。
Thanks! 谢谢!
它调整滚动视图边界,而不是内容插入。
self.view = self.scrollView;
Works fine for me. 对我来说很好。 Tested with UIWebview:
使用UIWebview测试:
- (void)viewDidLoad
{
[super viewDidLoad];
self.view = self.webView;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.