编辑UITableView的样式 - 添加/删除

时间:2011-05-24 06:03:29

标签: iphone objective-c uitableview

我在 UITableViewController 子类中添加了以下代码,它在屏幕截图中显示类似于单选按钮的内容,可以选择/取消选择它。选中的按钮确实有红色的刻度符号。什么是按钮意味着什么?

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 
return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert; 
}  

UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert

1 个答案:

答案 0 :(得分:1)

您使用的功能是从表格视图的列表中选择值/值。但在使用此函数之前,您必须在viewController中包含另外两个函数:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath  

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

您可以在其他地方使用列表的选定值,也可以在下一个viewController中。