解決:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.automaticallyAdjustsScrollViewInsets = NO;// 默認是YES
self.edgesForExtendedLayout = UIRectEdgeNone;// 推薦使用
}
原因:
在iOS 7中,蘋果引入了一個新的屬性,叫做[UIViewController setEdgesForExtendedLayout:],它的默認值為UIRectEdgeAll。當你的容器是navigation controller時,默認的布局將從navigation bar的頂部開始。這就是為什么所有的UI元素都往上漂移了44pt。