當(dāng)tableview加載的時(shí)候呜投,會(huì)調(diào)用UITableView的UITableViewDelegate和UITableViewDataSource里面對(duì)應(yīng)的方法:
首先:有三輪的調(diào)用下面的方法(聲明:實(shí)現(xiàn)這些方法才會(huì)去調(diào)用)
第一輪:
numberOfSectionsInTableView: (調(diào)用一次)
tableView:heightForHeaderInSection: (調(diào)用兩次)
tableView:heightForFooterInSection: (調(diào)用兩次)
tableView:numberOfRowsInSection: (調(diào)用一次)
tableView:heightForRowAtIndexPath: (調(diào)用次數(shù)和這組的行數(shù)一樣)
以上是一組cell的調(diào)用結(jié)果,如果有多組番宁,會(huì)重復(fù)上面的步驟
第二輪和第三輪的調(diào)用結(jié)果和第一輪一樣
緊接著:會(huì)調(diào)用以下方法(聲明:實(shí)現(xiàn)這些方法才會(huì)去調(diào)用)
tableView:cellForRowAtIndexPath: (調(diào)用一次)
tableView:heightForRowAtIndexPath: (調(diào)用一次)
tableView:accessoryTypeForRowWithIndexPath:(調(diào)用一次)
tableView:canEditRowAtIndexPath:(調(diào)用一次)
tableView:willDisplayCell:forRowAtIndexPath:(調(diào)用一次)
以上這幾個(gè)方法驻谆,會(huì)輪循調(diào)用多次泥兰,調(diào)用的次數(shù)和和當(dāng)前tableview里面可見(jiàn)的cell個(gè)數(shù)一樣
tableView:viewForHeaderInSection:
tableView:titleForHeaderInSection:
tableView:willDisplayHeaderView:forSection:
tableView:viewForFooterInSection:
tableView:titleForFooterInSection:
tableView:willDisplayFooterView:forSection:
以上這幾個(gè)方法笑旺,會(huì)輪循調(diào)用多次,調(diào)用的次數(shù)和和當(dāng)前tableview里面可見(jiàn)的header和footer個(gè)數(shù)一樣
當(dāng)cell有附加按鈕(就是左滑出來(lái)的按鈕)好唯,且cell是可編輯的:會(huì)調(diào)用以下方法(聲明:實(shí)現(xiàn)這些方法才會(huì)去調(diào)用)
tableView:editingStyleForRowAtIndexPath:
tableView:canEditRowAtIndexPath:
tableView:editingStyleForRowAtIndexPath:
tableView:canEditRowAtIndexPath:
tableView:willBeginEditingRowAtIndexPath:
tableView:accessoryTypeForRowWithIndexPath:
tableView:canEditRowAtIndexPath:
tableView:editingStyleForRowAtIndexPath:
tableView:canMoveRowAtIndexPath:
tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:
當(dāng)點(diǎn)擊cell有附加按鈕(就是左滑出來(lái)的按鈕)時(shí):會(huì)調(diào)用以下方法(聲明:實(shí)現(xiàn)這些方法才會(huì)去調(diào)用)
tableView:commitEditingStyle:forRowAtIndexPath:
當(dāng)cell有附加按鈕(就是左滑出來(lái)的按鈕)消失的時(shí)候:會(huì)調(diào)用以下方法(聲明:實(shí)現(xiàn)這些方法才會(huì)去調(diào)用)
tableView:didEndEditingRowAtIndexPath:
tableView:accessoryTypeForRowWithIndexPath:
tableView:canEditRowAtIndexPath:
tableView:didEndEditingRowAtIndexPath:
當(dāng)首次點(diǎn)擊cell時(shí)(tableview第一次顯示的時(shí)候):會(huì)調(diào)用一下方法(聲明:實(shí)現(xiàn)這些方法才會(huì)去調(diào)用)
tableView:shouldHighlightRowAtIndexPath:
tableView:didHighlightRowAtIndexPath:
tableView:didUnhighlightRowAtIndexPath:
tableView:willSelectRowAtIndexPath:
tableView:didSelectRowAtIndexPath:
當(dāng)再次單擊不同于當(dāng)前的cell時(shí):會(huì)調(diào)用以下方法(聲明:實(shí)現(xiàn)這些方法才會(huì)去調(diào)用)
tableView:shouldHighlightRowAtIndexPath:
tableView:didHighlightRowAtIndexPath:
tableView:didUnhighlightRowAtIndexPath:
tableView:willSelectRowAtIndexPath:
tableView:willDeselectRowAtIndexPath:
tableView:willDeselectRowAtIndexPath:
tableView:didDeselectRowAtIndexPath:
tableView:didSelectRowAtIndexPath:
當(dāng)長(zhǎng)按cell并離開(kāi)時(shí):會(huì)調(diào)用以下方法(聲明:實(shí)現(xiàn)這些方法才會(huì)去調(diào)用)
tableView:shouldHighlightRowAtIndexPath:
tableView:didHighlightRowAtIndexPath:
tableView:shouldShowMenuForRowAtIndexPath:
tableView:canPerformAction:forRowAtIndexPath:withSender: (會(huì)調(diào)用很多次)
tableView:didUnhighlightRowAtIndexPath: