iOS 8:【轉】UITableView 效能最佳化筆記

來源:互聯網
上載者:User

標籤:

源地址:http://fann.im/blog/2012/09/11/uitableview-optimization-notes/

Hacking Week 技術總結最後一篇,記一下 UITableView 效能最佳化需要注意和改進的地方。

  1. 網狀圖片非同步載入,SDWebImage。
  2. 文字直接 drawInRect/drawAtPoint 繪製,參考 ABTableViewCell,AdvancedTableViewCells。
  3. 本地圖片也可以直接繪製,或者用 CALayer 來添加顯示。
  4. cell 重用機制。
  5. cell 內容盡量避免透明效果。
  6. 如非必要,減少 reloadData 全部 cell,只 reloadRowsAtIndexPaths。
  7. 如果 cell 是動態行高,計算出高度後緩衝。tableView 會在載入的時候把全部 cell 的高度通過 heightForRowAtIndexPath: 都計算出來,即使 cell 還沒有展示。
  8. 如果 cell content 的展示位置也不固定,第一次計算後也要緩衝。
  9. cell 高度固定的話直接用 cell.rowHeight 設定高度,不要再實現 tableView:heightForRowAtIndexPath: delegate.
  10. cell content 的解析操作(尤其是複雜的解析)非同步進行+預執行,解析結果要緩衝。
  11. 可以積極式載入需要的網路資源(圖片等),SDWebImagePrefetcher.

There are performance implications to using tableView:heightForRowAtIndexPath: instead of the rowHeight property. Every time a table view is displayed, it calls tableView:heightForRowAtIndexPath: on the delegate for each of its rows, which can result in a significant performance problem with table views having a large number of rows (approximately 1000 or more). via Apple Document

iOS 8:【轉】UITableView 效能最佳化筆記

聯繫我們

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