問題:無(wú)論在storyboard上怎樣布局良好毯炮,模擬器上都會(huì)向下偏移64
解決方法:
- (void)viewDidLoad {
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets=NO;
}
有必要說(shuō)一下產(chǎn)生這個(gè)的原因:
在IOS7和以后的版本里,UIViewController 類里面增加了 automaticallyAjustScrollViewInsert 屬性桃煎。先從字面上翻譯一下:自動(dòng)調(diào)整插入的滑動(dòng)視圖。
官方文檔是這樣解釋的:
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.
翻譯一下:默認(rèn)值是YES三椿,選擇YES表示你允許視圖控制器調(diào)整它內(nèi)部插入的滑動(dòng)視圖來(lái)應(yīng)對(duì)狀態(tài)欄,導(dǎo)航欄搜锰,工具欄,和標(biāo)簽欄所消耗的屏幕區(qū)域蛋叼。如果你設(shè)置為NO呢,就代表你要自己調(diào)整你插入的滑動(dòng)視圖租冠,比如你的視圖層次里面有多于一個(gè)的滑動(dòng)視圖薯嗤。
這大概是個(gè)什么意思呢,就是你的視圖控制器在沒經(jīng)你允許的情況下調(diào)整你的控件位置了骆姐,所以你要想自己調(diào),對(duì)它設(shè)置NO就可以了玻褪。