- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我对 UIScrollView (iOS 7) 的理解:
contentOffset
定义内容 View 的原点contentInset
可以有效地在内容 View 周围添加“填充”在 Xcode 中,我创建了一个单 View 应用程序。在 IB 中,我向 View Controller 添加了一个 UIScrollView
,并将 Controller 嵌入到导航 Controller 中。在 View Controller 代码中,我添加了以下方法:
- (void)viewDidAppear:(BOOL)animated
{
[self.scrollView setContentSize:CGSizeMake(380, 1000)];
NSLog(@"top = %f, bounds top %f", self.scrollView.frame.origin.y, self.scrollView.bounds.origin.y);
NSLog(@"offset y = %f", self.scrollView.contentOffset.y);
NSLog(@"height = %f", self.scrollView.contentSize.height);
NSLog(@"inset top = %f", self.scrollView.contentInset.top);
NSLog(@"inset bottom = %f", self.scrollView.contentInset.bottom);
}
我的结果:
top = 0.000000, bounds top -64.000000
offset y = -64.000000
height = 1000.000000
top = 64.000000
bottom = 0.000000
contentInset.top
值有效地将内容向下移动,使其位于导航栏下方。为什么 contentOffset.y
设置为 -64,而 ScrollView 的边界设置为 -64?
提前致谢
最佳答案
因为 automaticallyAdjustsScrollViewInsets
默认值在 iOS 7.0 中是 YES
。
The default value of this property is YES, which lets container view controllers know that they should adjust the scroll view insets of this view controller’s view to account for screen areas consumed by a status bar, search bar, navigation bar, toolbar, or tab bar. Set this property to NO if your view controller implementation manages its own scroll view inset adjustments.
关于ios - contentOffset 和 contentInset 如何在 iOS 7 中为 UIScrollView 工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23435254/
我是一名优秀的程序员,十分优秀!