UITableViewDataSource TableView數據源協議,tableview
UITableViewDataSource TableView數據源協議
主要進行,資料的編輯(刪除,插入),索引,移動排序的操作,是否允許編輯(刪除,插入)和移動排序,設定顯示的行數,組數,儲存格的顯示
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
返回的是一組數據有多少行
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
cell訪問數據源然後加載到tableView
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView;
返回有多少組,多少部分(默認是1,這個方法可以不實現)
-(NSString *)tableView:(UITableView *) titleForHeaderInSection:(NSInteger)section;
(固定的字體fixed font style,如果你想要不同的樣子,使用 custom view(UILabel))
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
控制行能否移動,return NO就不能執行排序操作了(比如移動按鈕不會出現了)
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;
控制能否編輯,如果return NO 不能執行編輯操作了(比如刪除不會出現了)
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
要求的指定部分的表格視圖的頁首標題資料來源。
-(NSString *)tableVIew:(UITableView *)tableVIew titleForFooterInSection:(NSInteger)section;
要求的指定部分的表格視圖的頁尾標題資料來源。
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView;
返回每組的標題,標題顯示在索引檢視表中
-(Integer)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index;
返回分組的索引位置(在這個方法裡面可以接收到索引的標題是什麼,如果寫成固定的值,那麼點擊索引不會對應的跳動了)
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle) editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;
對特定的行進行刪除跟插入的操作(editingStyle,編輯類型,可以通過他來區分是刪除還是插入
)
-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;
對資料來源將排在表視圖中的一個特定的位置到另一個位置。(排序的操作用這個方法操作)