第三章:IOS Table表視圖委託協議和資料協議,iostable

來源:互聯網
上載者:User

第三章:IOS Table表視圖委託協議和資料協議,iostable

表視圖有兩個重要的協議

UITableViewDataSource :資料來源協議

 
方法 傳回型別 說明 必須實現
tableView:cellForRowAtIndexPath:
UITableViewCell*

   為表視圖儲存格提供資料,該方法是必 須實現的方法 

tableView:numberOfRowsInSection:
NSInteger
返回某個節中的行數
tableView:titleForHeaderInSection:
NSString
返回節頭的標題
tableView:titleForFooterInSection:
NSString
返回節腳的標題
numberOfSectionsInTableView:
NSInteger
返回節的個數
sectionIndexTitlesForTableView:
NSArray*
提供表視圖節索引標題
tableView:commitEditingStyle:forRowAtIndexPath:
void
為刪除或修改提供資料

 

UITableViewDelegate :委託協議,主要用來設定表視圖中節頭和節腳的標題,並響應一些動作事件 

 
方法 傳回型別 說明 是否需要實現

tableView:viewForHeaderInSection: 

UIView * 

為節頭準備自訂視圖,iOS 6之後可以使用 UITableViewHeaderFooterView 

tableView:viewForFooterInSection: 

UIView * 

為節腳準備自訂視圖,iOS 6之後可以使用 UITableViewHeaderFooterView 

tableView:didEndDisplayingHeaderView:forSection: 

void 

該方法在節頭從螢幕中消失時觸發(iOS 6之後 的方法) 

tableView:didEndDisplayingFooterView:forSection: 

void 

當節腳從螢幕中消失時觸發(iOS 6之後的方法) 

tableView:didEndDisplayingCell:forRowAtIndexPath: 

void 

當儲存格從螢幕中消失時觸發(iOS 6之後的方法) 

tableView:didSelectRowAtIndexPath: 

void 

響應選擇表視圖儲存格時調用的方法 

 

 

聯繫我們

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