例如当我们的一个类中有有一个scrollview和tableview,这个时间scrollview在滑动的时间会出现上下偏移的问题 ,很是怪异,设置都没问题,这个时间大家可以试试
self.automaticallyAdjustsScrollViewInsets=NO;
这句话其实这一切都是automaticallyAdjustsScrollViewInsets在作怪,它默认是yes,
官方文档中对它的描述:
automaticallyAdjustsScrollViewInsets
Specifies whether or not the view controller should automatically adjust its scroll view insets.
@property(nonatomic, assign) BOOL automaticallyAdjustsScrollViewInsets
Discussion
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 toNO 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.
Declared In
UIViewController.h
由此可见,当我们一个界面有多个删除rollview子视图时,要将它设置为NO,完全由自己手动来布局,就不会错乱了.