@protocol UITableViewDataSource<NSObject>
@required
//设置分组的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
//创建cell,每一个行(row)对应一个cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
@optional
//设置分组个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
//设置分组头(标题)显示的文字
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
//设置UITableView右边的索引值
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView;
//设置每一行的编辑状态
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;
//按钮点击事件
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;
//设置tableView每一行是否允许移动
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath;
//提交移动之后触发
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;
UITableViewDelegate
//设置每行row的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
//设置tableViewCell的编辑样式(插入/删除)
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
//设置当点击删除按钮时,提示的确认文字
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPathNS_AVAILABLE_IOS(3_0){
return@"确认删除";
}
//移动时只能在本区内移动(设置cell移动的位置)
- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath;