iOS 11 與 iPhone X的適配那些事

來源:互聯網
上載者:User

標籤:ram   cap   instead   tps   導致   san   hone   target   com   

前言

9月20日,正式推送Xcode 9和iOS 11的正式版,適配iOS 11是首要的適配的,網上教程很多,不在贅述。這裡主要講的是iPhone X的適配大神層級的可以不用看,我這裡講的主要是基礎的適配工作

  摘要

  啟動圖:1125 * 2436 
  statusBar高度:44 
  tabbar高度:83

  • 啟動應用程式

對於一些老項目,在啟動圖上,可能沒有採用XIB或者SB進行適配的,所以可能會出現一,這樣導致整個項目運行就會不能完全貼合。


![上傳login2_194373.png。。]

解決辦法,在項目設定裡面直接用LaunchScreen.xib或者LaunchScreen.storyboard進行配置啟動圖,這樣項目就會完整顯示了

 


iPhone X LaunchImage.png

 


iPhone X LaunchImage2.png
    login2.png
  • TableView - > MJRefresh

出現下拉重新整理的尾巴,該問題很好解決,在文檔中標註很明白

1 @property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets API_DEPRECATED_WITH_REPLACEMENT("Use UIScrollView‘s contentInsetAdjustmentBehavior instead", ios(7.0,11.0),tvos(7.0,11.0)); // Defaults to YES
contentInsetAdjustmentBehavior對於我們現在來說是個陌生面孔。這是在iOS11為中ScrollView新定義的一個枚舉屬性。
注意,談到上面的automaticallyAdjustsScrollViewInsets的英文控制器的屬性。
1 typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior) {2     UIScrollViewContentInsetAdjustmentAutomatic, // Similar to .scrollableAxes, but for backward compatibility will also adjust the top & bottom contentInset when the scroll view is owned by a view controller with automaticallyAdjustsScrollViewInsets = YES inside a navigation controller, regardless of whether the scroll view is scrollable3     UIScrollViewContentInsetAdjustmentScrollableAxes, // Edges for scrollable axes are adjusted (i.e., contentSize.width/height > frame.size.width/height or alwaysBounceHorizontal/Vertical = YES)4     UIScrollViewContentInsetAdjustmentNever, // contentInset is not adjusted5     UIScrollViewContentInsetAdjustmentAlways, // contentInset is always adjusted by the scroll view‘s safeAreaInsets6 } API_AVAILABLE(ios(11.0),tvos(11.0));

 

iOS 11中的estimatedXXHeight由預設的0變成了現在的預設.AutomaticDimension,導致高度計算出錯,最後導致的現象就是上拉載入更多的時候UI錯亂,TableView視圖的高度異常等一系列問題。

 1  if (@available(iOS 11.0, *)) { 2         _newtableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; 3         //以下是tableview高度計算出現問題 4         _newtableView.estimatedRowHeight = 0; 5         _newtableView.estimatedSectionHeaderHeight=0; 6         _newtableView.estimatedSectionFooterHeight=0; 7          8   }else{ 9         self.automaticallyAdjustsScrollViewInsets = NO;10   }

 

iOS 11 NavigationBar新特性

Navigation整合UISearchController
把你的UISearchController賦值給navigationItem,可以就實現將UISearchController整合到Navigation

1 navigationItem.searchController  //iOS 11 新增屬性2 navigationItem.hidesSearchBarWhenScrolling //決定滑動的時候是否隱藏搜尋方塊;iOS 11 新增屬性

 

@property (nonatomic, retain, nullable) UISearchController *searchController API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos);

 

總結:

iOS11系統改變還是比較大的,某些地方需要注意適配,不然會出現很奇怪的現象。暫時,在iOS11遇到這麼多坑,以後遇到會繼續分享的。
第一次寫文章,多謝關照

參考:

開發人員所需要知道的iOS 11 SDK新特性
iOS 11導覽列高度自訂
iOS 11 UIKitの変更點

 

原文地址:http://www.jianshu.com/p/fed93b411eb6

iOS 11 與 iPhone X的適配那些事

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.