5. }
- (UITableViewCell *)tableView:(UITableView *)table{ //设置背景颜色cell.contentView.backgroundColor=[U} (11) - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath 这个函数响应,用户点击cell 右边的箭头(如果有的话) (12)如何设置tableview 可以被编辑 首先要进入编辑模式: [cpp]view plaincopyprint? 1. [TableView setEditing:YES animated:YES];
[TableView setEditing:YES animated:YES]; 如果要退出编辑模式,肯定就是设置为NO - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 返回当前cell 要执行的是哪种编辑,下面的代码是返回删除模式
[cpp]view plaincopyprint?
1. - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 2. {
3. return UITableViewCellEditingStyleDelete; 4. }
- (UITableViewCellEditingStyle)tableView:(UITableVi{ return UITableViewCellEditingStyleDelete;} -(void) tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle) editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 通知告诉用户编辑了哪个cell,对应上面的代码,我们在这个函数里面执行删除cell的操作。 [cpp]view plaincopyprint? 1. -(void) tableView:(UITableView *)aTableView
2. commitEditingStyle:(UITableViewCellEditingStyle) editingStyle 3. forRowAtIndexPath:(NSIndexPath *)indexPath 4. {
5. [chatArray removeObjectAtIndex:indexPath.row]; 6. [chatTableView reloadData]; 7. }
-(void) tableView:(UITableView *)aTableViewcommitEditingStyle:(UITableViewCellEditingStyle) edforRowAtIndexPath:(NSIndexPath *)indexPath{ [chatArray removeObjectAtIndex:indexPath.r[chatTableView reloadData];} (13)如何获得某一行的CELL对象 - (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;