iOS11&iPhoneX適配&Xcode9打包注意事項

來源:互聯網
上載者:User

標籤:oda   self   就是   ini   edr   dev   tom   sso   view   

轉自:

http://blog.csdn.net/smile_po/article/details/78341685

http://blog.csdn.net/sodaslay/article/details/78191227

一 升級iOS11適配

1.1,適配UITableView

if#available(iOS11.0, *) {self.contentInsetAdjustmentBehavior= .neverself.estimatedRowHeight=0self.estimatedSectionHeaderHeight=0self.estimatedSectionFooterHeight=0}else{}

1.2,適配UIScrollView

if#available(iOS11.0, *) {scrollView?.contentInsetAdjustmentBehavior= .never}else{}

1.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。

1.4,適配網頁載入不全下面有白邊

if#available(iOS11.0, *) {webView.scrollView.contentInsetAdjustmentBehavior= .never}else{}

1.5 如果使用了Masonry 進行布局,就要適配safeArea

if ([UIDevice currentDevice].systemVersion.floatValue >= 11.0) {         make.edges.equalTo(self.view.safeAreaInsets);  } else {       make.edges.equalTo(self.view);   }
二 iphoneX適配

2.1 適配iPhoneX不能鋪滿屏的問題

方案一:給Brand Assets添加一張1125*2436大小的圖片,開啟Assets.xcassets檔案夾,找到Brand Assets,右鍵Show in Finder,添加一張1125*2436大小的圖片。

方案二:修改Contents.json檔案,添加如下內容

{"extent" : "full-screen","idiom" : "iphone","subtype" : "2436h","filename" : "1125_2436.png”,"minimum-system-version" : "11.0","orientation" : "portrait","scale" : "3x"}

2.2 適配iphoneX

//適配iPhoneXlet LL_iPhoneX = (kScreenW == Double(375.0) && kScreenH == Double(812.0) ?true:false)let kNavibarH = LL_iPhoneX ? Double(88.0) : Double(64.0)let kTabbarH = LL_iPhoneX ? Double(49.0+34.0) : Double(49.0)let kStatusbarH = LL_iPhoneX ? Double(44.0) : Double(20.0)

2.3 裝置資訊

if ([deviceString isEqualToString:@"iPhone10,1"])  return @"iPhone 8";if ([deviceString isEqualToString:@"iPhone10,4"])  return @"iPhone 8";if ([deviceString isEqualToString:@"iPhone10,2"])  return @"iPhone 8 Plus";if ([deviceString isEqualToString:@"iPhone10,5"])  return @"iPhone 8 Plus";if ([deviceString isEqualToString:@"iPhone10,3"])  return @"iPhone X";if ([deviceString isEqualToString:@"iPhone10,6"])  return @"iPhone X";
三 Xcode9打包

xcode9打包版本只能是8.2及以下版本,或者9.0及更高版本

iOS11&iPhoneX適配&Xcode9打包注意事項

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.