iOS11 (iPhone X)適配中遇到的問(wèn)題

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)注意

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容