iOS 7——navigationController 正在设置我的 UIScrollView 的 contentIns

iOS 7 -- navigationController is setting the contentInset and ContentOffset of my UIScrollView(iOS 7——navigationController 正在设置我的 UIScrollView 的 contentInset 和 ContentOffset)
本文介绍了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 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.

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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
Resume game cocos2d(恢复游戏 cocos2d)
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)
How can I implement a virtual joystick for a cocos2d game outside the cocos2d environment?(如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?)