问题:无论在storyboard上怎样布局良好,模拟器上都会向下偏移64 
解决方法:
- (void)viewDidLoad {
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets=NO;
}有必要说一下产生这个的原因:
在IOS7和以后的版本里,UIViewController 类里面增加了 automaticallyAjustScrollViewInsert 属性。先从字面上翻译一下:自动调整插入的滑动视图。
官方文档是这样解释的:
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 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.
翻译一下:默认值是YES,选择YES表示你允许视图控制器调整它内部插入的滑动视图来应对状态栏,导航栏,工具栏,和标签栏所消耗的屏幕区域。如果你设置为NO呢,就代表呀你要自己调整你插入的滑动视图,比如你的视图层次里面有多于一个的滑动视图。
这大概是个什么意思呢,就是你的视图控制器在没经你允许的情况下调整你的控件位置了
,所以你要想自己调,对它说NO就可以了。
本文探讨了在iOS开发中遇到的布局偏差问题,并提供了解决方案。通过设置UIViewController的automaticallyAdjustsScrollViewInsets属性为NO,可以避免视图控制器在模拟器上向下偏移的情况。文章详细解释了该属性的作用及原因。
569

被折叠的 条评论
为什么被折叠?



