天天看點

iOS UITableView~datasource(資料源方法)

//聯系人:石虎  QQ: 1224614774昵稱:嗡嘛呢叭咪哄

一、UITableView的datasource實作:

//回調擷取每個section中的cell的行數

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

//回調擷取每個uitableviewcell,隻有當需要顯示的cell在table的可視區域内才被回調

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

//回調擷取table的section數量

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

//回調擷取table的每個section的header标題

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

//回調擷取table的每個section的footer标題

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

//回調判斷指定的cell是否能有編輯狀态

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath

//回調判斷指定的cell能否被移動當進入編輯模式的時候

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath

//回調擷取table右邊的索引欄内容

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

//當點選右邊索引欄時執行的回調,可以根據點選的title值傳回應該跳到第幾個section

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index

//當所有相關編輯模式的回調,隻實作該回調時預設能滑動cell出現删除按鈕。當和其他相關的編輯模式回調混合使用分别有移動,插入,删除等功能

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

//當進入的是移動的編輯模式時,實作該回調進行移動cell和資料的更新

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath

謝謝!!!