1辣之、tableView或者collectionView向下偏移
原因是iOS 11中Controller的automaticallyAdjustsScrollViewInsets屬性被廢棄了嘹锁,所以當tableView超出安全區(qū)域時系統(tǒng)自動調(diào)整了SafeAreaInsets值,進而影響adjustedContentInset值堵未,在iOS 11中決定tableView的內(nèi)容與邊緣距離的是adjustedContentInset屬性,而不是contentInset米丘。因為系統(tǒng)對adjustedContentInset值進行了調(diào)整蚕甥,所以導致tableView的內(nèi)容到邊緣的距離發(fā)生了變化蝌以,導致tableView下移了20pt(statusbar高度)或64pt(navigationbar高度)。
如果你的APP中使用的是自定義的navigationbar何之,隱藏掉系統(tǒng)的navigationbar跟畅,并且tableView的frame為(0,0,SCREEN_WIDTH, SCREEN_HEIGHT)開始,那么系統(tǒng)會自動調(diào)整SafeAreaInsets值為(20,0,0,0)溶推,如果使用了系統(tǒng)的navigationbar徊件,那么SafeAreaInsets值為(64,0,0,0),如果也使用了系統(tǒng)的tabbar蒜危,那么SafeAreaInsets值為(64,0,49,0)虱痕。
解決方法:
#ifdef __IPHONE_11_0
if ([_collectionView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
_collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
#endif
2、導航欄translucen = NO的時候x = 0,y = 0的點在左上角而不是導航欄底下
controller中加這行代碼
self.edgesForExtendedLayout = UIRectEdgeNone;