怎么处理使用UINavigation(导航控制器时) UIScrollView及其子类UITableView、UICollectionView可能出现的向下偏移64Px或者顶部对齐等问题

前言

          近期在做项目时遇到了好几起由于自动偏移或则没有自动偏移而导致的界面布局问题,尤其是在昨晚新版本赶上IOS9系统升级的时候,刚升级完了后就发现项目里面很多使用UINavgation控制器管理的ViewController里的TableView出现了不同程度的怪异现象,有些TableView直接以Frame的原点(0.0)为起始坐标点,有的则是以(0.128)为起始点,正确的应该是以(0.64)作为起始点,当时为了赶时间,于是就采取了笨办法,通过判断版本来手动调节远点的位置,接下来将介绍一下新的解决思路,这将会很好的解决这类问题

相关资料

官方链接:https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/TransitionGuide/AppearanceCustomization.html

在iOS7新增了几个ViewController的属性用来adjust(调整)ViewController和Bar之间的布局关系

目前我主要用到的就是这个属性:edgesForExtendedLayout

官方解释:

The edgesForExtendedLayout property uses the UIRectEdge type, which specifies each of a rectangle’s four edges, in addition to specifying none and all.

Use edgesForExtendedLayout to specify which edges of a view should be extended, regardless of bar translucency. By default, the value of this property is UIRectEdgeAll.

也就是说这个属性是用来指定ViewController的边缘样式的,不管状态栏是不是半透明的,该属性只适用于导航控制器管理的ViewController,类型为UIRectEdge可以设置(None,Top,Left,Bottom,Right,All)等属性

在interface bundler 中在下图位置进行设置调节设置

Screen Shot 2015 10 06 at 11 10 23 AM

有时间再对其余的属性进行扩展

原文地址:https://www.cnblogs.com/SuPair/p/4856871.html