ios - 尽管 contentSize 正确,UIScrollview 仍会垂直滚动

标签 ios objective-c iphone uiview uiscrollview

我在 UIScrollView 中有一个 UIView。 UIScrollView 具有以下约束:

-Top space to superview equals 0
-Leading space to superview equals 0
-Width equals 320.0f
-Height equals 45.0

UIView 具有以下约束:
-Top space to superview equals 0
-Bottom space to superview equals 0
-Leading space to superview equals 0
-Trailing space to superview equals 0
-Width equals 320.0
-Height equals 45.0

据我所知,这应该禁用所有滚动。但是,我仍然可以垂直滚动到 49.0 的最大偏移量。所有尺寸似乎都是正确的:
(lldb) po scrollView.contentSize
(width=420, height=45)
 {
  320

  45

}
(lldb) po scrollView
<UIScrollView: 0x10c332980; frame = (0 0; 320 45); clipsToBounds = YES; autoresize = RM+TM; gestureRecognizers = <NSArray: 0x10c333b80>; layer = <CALayer: 0x10c32c530>; contentOffset: {0, 49}>
(lldb) po contentView
<UIView: 0x10c332400; frame = (0 0; 320 45); autoresize = W+H; layer = <CALayer: 0x10c3324c0>>

但是 UIScrollView 仍然能够垂直滚动。有谁知道这怎么可能?

编辑:

新信息:问题仅出现在 iOS 7.1 上,而不是 iOS 6.1

最佳答案

最终我发现 ScrollView 的底部内容插入不是 0 而是 49。目前还不清楚它是如何获得一个值的,因为它没有在布局编辑器中设置,但我能够禁用垂直滚动如下:

[scrollView setContentInset:UIEdgeInsetsZero];

关于ios - 尽管 contentSize 正确,UIScrollview 仍会垂直滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25741248/

相关文章:

ios - 删除 UINavigationBar 下的 1px 边框 - 不起作用

iphone - 在 iPad/iPhone 上创建图表

iphone - 在 iPhone 应用程序开发中,如何将数据存储到文本文件中并在应用程序再次启动时检索它?

php - 通过 PHP 联系页面从 iPhone 发送电子邮件

iphone - 如何在应用程序中引用每个 UILabel

ios - Swift - 减少 UICollectionViewCell 之间的间隙

ios - GuardMalloc 导致虚拟内存耗尽

objective-c - TableView 无/不更新

ios - 在后台连续运行的iOS游戏

iphone - 错误 : The bundle uses a bundle name or display name associated with an Apple app