【问题标题】:How to change the edit button action in iphone如何更改 iPhone 中的编辑按钮操作
【发布时间】:2011-11-09 11:59:21
【问题描述】:
我有一个UITableView,在其中我添加了一个左侧导航栏UIBarButtonItem 来编辑表格的内容。当我单击编辑按钮时,我的每个 UITableViewCell 之前都会出现删除按钮。
我为编辑按钮写了一个selector,但是当我默认点击它时,它会在每个单元格之前显示删除按钮。我需要的是,当我点击编辑按钮而不是删除按钮时,应该在每个单元格右侧显示一个披露按钮。
【问题讨论】:
标签:
iphone
objective-c
uibarbuttonitem
【解决方案1】:
您是否在编辑按钮选择器中打开了表格视图编辑模式?
也许通过使用类似的东西:
[tableView setEditing: YES animated: YES];
相反,您可以遍历表格的所有单元格并设置附件类型
for (int section = 0; section < [tableView numberOfSections]; section++) {
for (int row = 0; row < [tableView numberOfRowsInSection:section]; row++) {
NSIndexPath* cellPath = [NSIndexPath indexPathForRow:row inSection:section];
UITableViewCell* cell = [tableView cellForRowAtIndexPath:cellPath];
cell.accesoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
虽然我不确定当单元被合并和重用时这是否有效。