iOS11&iPhoneX適配&Xcode9打包注意事項
1,適配UITableView
1 2 3 4 5 6 7 |
if #available(iOS11. 0 , *) {
self.contentInsetAdjustmentBehavior= .never
self.estimatedRowHeight= 0
self.estimatedSectionHeaderHeight= 0
self.estimatedSectionFooterHeight= 0
} else {
}
|
2,適配UIScrollView
1 2 3 4 |
if #available(iOS11. 0 , *) {
scrollView?.contentInsetAdjustmentBehavior= .never } else {
}
|
3,UITableView中的sectionHeader或者Footer顯示不正常
還有的發現某些介面tableView的sectionHeader、sectionFooter高度與設定不符的問題,在iOS11中如果不實現-tableView: viewForHeaderInSection:和-tableView: viewForFooterInSection:,則-tableView: heightForHeaderInSection:和- tableView: heightForFooterInSection:不會被呼叫,導致它們都變成了預設高度,這是因為tableView在iOS11預設使用Self-Sizing,tableView的estimatedRowHeight、estimatedSectionHeaderHeight、estimatedSectionFooterHeight三個高度估算屬性由預設的0變成了UITableViewAutomaticDimension,解決辦法簡單粗暴,就是實現對應方法或把這三個屬性設為0。
4,適配網頁載入不全下面有白邊
1 2 3 4 |
if #available(iOS11. 0 , *) {
webView.scrollView.contentInsetAdjustmentBehavior= .never
} else {
}
|
5,適配iPhoneX不能鋪滿屏的問題
<1>給Brand Assets新增一張1125*2436大小的圖片
開啟Assets.xcassets資料夾,找到Brand Assets
右鍵Show in Finder
新增一張1125*2436大小的圖片
<2>修改Contents.json檔案,新增如下內容
1 2 3 4 5 6 7 8 9 |
{
"extent" : "full-screen" ,
"idiom" : "iphone" ,
"subtype" : "2436h" ,
"filename" : "1125_2436.png”,
"minimum-system-version" : "11.0" ,
"orientation" : "portrait" ,
"scale" : "3x"
}
|
6,適配iPhoneX
1 2 3 4 5 |
//適配iPhoneX
letLL_iPhoneX = (kScreenW == Double( 375.0 ) && kScreenH == Double( 812.0 ) ? true : false )
letkNavibarH = LL_iPhoneX ? Double( 88.0 ) : Double( 64.0 )
letkTabbarH = LL_iPhoneX ? Double( 49.0 + 34.0 ) : Double( 49.0 )
letkStatusbarH = LL_iPhoneX ? Double( 44.0 ) : Double( 20.0 )
|
7,xcode9打包注意事項
xcode9打包版本只能是8.2及以下版本,或者9.0及更高版本
xcode9不支援8.3和8.4版本