• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

iOS 7——navigationController 正在设置我的 UIScrollView 的 contentInset 和 ContentOffset

用户头像
it1352
帮助1

问题说明

我有一个 UIScrollView(实际上是一个 UICollectionView,但这可能无关紧要).当它出现在 IOS 7 中时,导航控制器将其 contentInset 和 contentOffset 设置为我不想要的值.它似乎正在尝试调整状态栏和导航栏.我非常希望它让他们一个人呆着.我已经通过覆盖 contentInset 和 contentOffset 的 getter 和 setter 方法来解决这个问题,并带有一个标志来告诉对象它是否应该接受一个集合.但是有没有更好的方法?

I have a UIScrollView (actually a UICollectionView, but that probably doesn't matter). When it appears in IOS 7, the navigation controller sets its contentInset and contentOffset to values I don't want. It appears to be trying to adjust for the status bar and the navigation bar. I'd greatly prefer it left them alone. I've fixed this by overriding the getter and setter methods for contentInset and contentOffset, with a flag to tell the object whether or not it should accept a set. But is there a better way?

正确答案

#1

尝试在主视图控制器中设置 self.automaticallyAdjustsScrollViewInsets = NO.

Try setting self.automaticallyAdjustsScrollViewInsets = NO in your main view controller.

这是在 iOS 7 中引入的,因此如果您支持 iOS 6 及更低版本,您可能需要使用 iOS 版本检查来包装它.

This was introduced in iOS 7 so you might want to wrap that with an iOS version check, if you are supporting iOS 6 and below.

更新

如果您使用情节提要,您可以在 Interface Builder 中执行此操作,也可以为您选择的控制器选中 'Adjust Scroll View Insets'.

If you are using storyboards, you can do this in the Interface Builder as well as by checking 'Adjust Scroll View Insets' for your selected controller.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tangicbcc
系列文章
更多 icon
同类精品
更多 icon
继续加载