iOS 7——navigationController 正在设置我的 UIScrollVi

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)