iOS 7 - navigationController正在设置我的UIScrollView的contentInset和ContentOffset [英] iOS 7 -- navigationController is setting the contentInset and ContentOffset of my UIScrollView

查看:124
本文介绍了iOS 7 - navigationController正在设置我的UIScrollView的contentInset和ContentOffset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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?

推荐答案

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

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

这是在 iOS 7 中引入的,所以你可能想用iOS版本检查,如果您支持 iOS 6 及以下。

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中执行此操作,也可以选中为您选择的控制器'调整滚动视图插入'

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.

这篇关于iOS 7 - navigationController正在设置我的UIScrollView的contentInset和ContentOffset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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