您的位置:首页 > 产品设计 > UI/UE

Xcode5上关于UINavigationController的rootVC上贴scrollView的一个坐标问题

2013-11-20 13:07 344 查看
前提:

1. 存在导航栏-UINavigationController。

2. rootViewController上的子view有个是自定义的继承于UIScrollView的view。

3. 该子view上面也有子view,并且坐标都是从零零开始的。

4. IOS7上运行。

rootVC上的子视图的坐标如果是从零零开始的,它的子view坐标会正常,但是如果不是从零零开始的,它的子view坐标就不正常了,很奇怪。刚开始以为这应该算是一个未优化好的bug,但后来找到了的解决方案:

UIViewController在IOS7.0以后新增了一个属性,默认是YES,只需把这个属性设为NO就行了(不过要记得调方法之前判断是否是IOS7系统啊,要不然在6上运行就崩了)。

@property(nonatomic, assign) BOOL automaticallyAdjustsScrollViewInsets

Description

Specifies whether or not the view controller should automatically adjust its scroll view insets.

Default value is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to NO if you want to manage scroll view inset adjustments yourself,
such as when there is more than one scroll view in the view hierarchy.

Availability Available in iOS 7.0 and later.

IOS技术闲聊群:172158202

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: