[iOS基礎控制項,ios基礎控制項

來源:互聯網
上載者:User

[iOS基礎控制項,ios基礎控制項
A.需要掌握的1.基本屬性和方法

  • 設定UITableView的dataSource、delegate
  • UITableView多組資料和單組資料的展示
  • UITableViewCell的常見屬性
  • UITableView的效能最佳化(cell的迴圈利用)
  • 自訂cell
 2.UITableView的概念UITableView就是表格式資料UITableView繼承自UIScrollView,支援垂直滾動,而且效能好 3.UITableView的兩種樣式
  • UITableViewStylePlain
  • UITableViewStyleGrouped
  4.展示資料
  • UITableView需要一個資料來源dataSource來顯示資料
  • UITableView向資料來源查詢一共有多少行資料和每一行的顯示內容
  • 沒有資料來源的UITableView只是個空殼
  • 凡是遵守了UITableViewDataSource協議的OC對象,都可以是UITableView的資料來源
 5.UITableView和資料來源
1 // 資料總組數2 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;              // Default is 1 if not implemented3  4 // 每組資料的行數5 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;6  7 // 每一行顯示的內容8 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
 資料來源引用:
1 // 資料來源2 @property(nonatomic, assign) id<UITableViewDataSource> dataSource;
 6.UITableView展示資料的過程(1)得到資料的組數
1 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
 (2)得到每組資料的行數
1 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
 (3)得到每行資料的內容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
 7.解析.plist檔案,將資料群組中的每個Dictionary用Model封裝起來儲存 8.使用MVC模式M: ModelV: ViewC: Control 9.Cell簡介  10.UITableViewCell的contentView   11.UITableViewCell的結構  12.Cell重用原理     為了應對大量資料的載入和顯示,不必建立相同數量的Cell,只需要把當前需要顯示的資料載入到cell上就行了。     原理:滾動列表,移出視窗的UITableViewCell會被放入到一個對象池中,當有資料需要顯示的時候,就會從對象池中取出可用的UITableViewCell,然後載入資料顯示。 13.自訂的cell重用     有時候為了特定的需求,需要自訂繼承自UITableViewCell的類,可能一個UITableView中存在多種cell,會造成對象池中cell類型的混亂。     解決:利用UITableViewCell的 NSSting *reuseIdentifier 屬性,初始化cell的時候指定reuseIdentifier,這樣在對象池取出cell對象的時候要先通過這個字串標識檢查,如果不存在就是使用傳入的字串標識初始化一個cell對象。 14.cell重用代碼      

相關文章

聯繫我們

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