UITableView的基礎知識 IOS

2021-06-27 16:06:35 字數 2783 閱讀 8429

ios- 顯示資料列表最常用的乙個控制項

1.uitableview裡的結構圖                       

2.uitableview資料展示的條件                      

1> uitableview的所有資料都是由資料來源(datasource)提供的,所以要想在uitableview展示資料,必須設定uitableview的datasource資料來源物件

2> 要想當uitableview的datasource物件,必須遵守uitableviewdatasource協議,實現相應的資料來源方法

3> 當uitableview想要展示資料的時候,就會給資料來源傳送訊息(呼叫資料來源方法),uitableview會根據方法返回值決定展示怎樣的資料

3.資料展示的過程                             

資料顯示,三步走

1> 先呼叫資料來源的

- (nsinteger)numberofsectionsintableview:(uitableview *)tableview

得知一共有多少組

2> 然後呼叫資料來源的

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section

得知第section組一共有多少行

3> 然後呼叫資料來源的

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath

得知第indexpath.section組 第indexpath.row 行顯示怎樣的cell(顯示什麼內容)

4.開發中經常用到的uitableview資料來源方法               

1> 一共有多少組

- (nsinteger)numberofsectionsintableview:(uitableview *)tableview

@required  2.3 是必須實現

2> 第section組一共有多少行

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section

3> 第indexpath.section組 第indexpath.row行顯示怎樣的cell(顯示什麼內容)

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath

4> 第section組顯示怎樣的頭部標題

- (nsstring *)tableview:(uitableview *)tableview titleforheaderinsection:(nsinteger)section;

5> 第section組顯示怎樣的尾部標題

- (nsstring *)tableview:(uitableview *)tableview titleforfooterinsection:(nsinteger)section;

5.開發中經常用到的uitableview**方法               

1.- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath

選中了uitableview的某一行

2.- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath

某一行的高度

3.- (cgfloat)tableview:(uitableview *)tableview heightforheaderinsection:(nsinteger)section

第section分割槽頭部的高度

4.- (cgfloat)tableview:(uitableview *)tableview heightforfooterinsection:(nsinteger)section

第section分割槽尾部的高度

5.- (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section

第section分割槽頭部顯示的檢視

6.- (uiview *)tableview:(uitableview *)tableview viewforfooterinsection:(nsinteger)section

第section分割槽尾部顯示的檢視

7.- (nsinteger)tableview:(uitableview *)tableview indentationlevelforrowatindexpath:(nsindexpath *)indexpath

設定每一行的等級縮排(數字越小,等級越高)

6.tableview重新整理資料的方式                      

1> 修改模型資料

2> 重新整理**

- reloaddata

整體重新整理(每一行都會重新整理)

- (void)reloadrowsatindexpaths:(nsarray *)indexpaths withrowanimation:(uitableviewrowanimation)animation

區域性重新整理

UITableView 基礎知識

uitableview 其中uitableviewstyle是乙個列舉,有兩種方式 uitableviewstyleplain,不自動分組的。uitableviewstylegrouped 具有分組功能。5.接下來就是兩個屬性 rowheight 行高 separatorcolor 分割線的顏色。6...

Android tensorflow 基礎知識學習

今天記錄下tensorflow的一些基本知識 1.匯入tensorflow 庫,且指令碼中新增執行使用的python環境 user bin env python import tensorflow as tf 匯入tensorflow庫 匯入 mnist 資料集 資料在linux 根目錄 data下...

Hyperledger Fabric 基礎知識筆記

區塊鏈可以幫助在競爭者之間或具有相反商業利益的組織之間建立信任,這可能導致爭執。資產在hyperledger fabric中表示為鍵值對的集合,狀態更改記錄為通道 分類賬中的事務。資產可以二進位制和 或json形式表示。chaincode是定義一項或多項資產的軟體,以及用於修改資產的交易指令 換句話...