1. 判斷是否是iPhone X?
#define IS_IPHONE_X ([[UIScreen mainScreen] bounds].size.height == 812.0)
判斷是否是iOS 11
#define IOS11? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (DeviceSystemVersionBigThan(11.0)||DeviceSystemVersionEqualTo(11.0))
2. UITableView上方出現(xiàn)空白問(wèn)題解決方案
if (IOS11) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
3. UITableView高度不對(duì)問(wèn)題,setContentOffset:和scrollRectToVisible:失效問(wèn)題
self.tableView.estimatedRowHeight = 0;
4. UINavigationItem的titleView不居中問(wèn)題
iOS11titleView的實(shí)現(xiàn)有變化,需要找到titleView的superView,然后將superView的x設(shè)置為0即可
5. 界面與safe area重疊問(wèn)題(iPhone X)
下面是蘋(píng)果文檔,大概意思就是要避免在iPhone X屏幕最下方放置可交互的控件
Avoid explicitly placing interactive controls at the very bottom of the screen and in corners.People use swipe gestures at the bottom edge of the display to access the Home screen and app switcher, and these gestures may cancel custom gestures you implement in this area. The far corners of the screen can be difficult areas for people to reach comfortably.
解決方案就是減去相應(yīng)的高度
if (IS_IPHONE_X) {
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, height-24) style:UITableViewStylePlain];
} else {
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth,height) style:UITableViewStylePlain];
}
6. iPhone X上UITabBarController的tabBar高度問(wèn)題
iPhone X上的UITabBar默認(rèn)高度為83,所以使用的時(shí)候應(yīng)注意