我有一个UITableview,我把它放在一个JASidePanel控制器(https://github.com/gotosleep/JASidePanels)我已经在我的init方法中设置了委托和数据源,并且我已经实现了canEditRowAtIndexPath方法,并且在我滑动时正在调用它们在tableview单元格上,但没有任何事情发生。我查看了其他问题,并已实施所有建议,但无法显示删除按钮。有谁知道什么会导致这种行为?UITableViewCell删除按钮不出现
0
A
回答
7
您必须实施tableView:editingStyleForRowAtIndexPath:
委托方法和tableView:commitEditingStyle:forRowAtIndexPath:
数据源方法。没有这些,删除将不会出现在单元格中。
我假设您从tableView:canEditRowAtIndexPath:
数据源方法(至少对于相应的行)返回YES
。
1
您是否尝试过使用此类自己的删除单元格的方法?
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (UITableViewCellEditingStyleDelete) {
int k = [[tempArray objectAtIndex:indexPath.row] intValue];
//Remove object from index 'k'.
}
}
它可能会帮助你。
谢谢。
0
在刷新TableViewCell时对UITableView执行删除操作。我们必须执行以下三种方法: -
此方法将在滑动TableViewCell时显示删除按钮。
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
NSUInteger count = [posts count];
if (row < count) {
return UITableViewCellEditingStyleDelete;
} else {
return UITableViewCellEditingStyleNone;
}
}
当用户删除TableViewCell的刷卡及刷行的行这种方法被称为将在敲击按钮,删除被删除。
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
NSUInteger count = [posts count];
if (row < count) {
[posts removeObjectAtIndex:row];
}
}
最后调用此方法在删除行后更新表视图。
- (void)tableView:(UITableView *)tableView
didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath {
[self updateViewTitle];
[tableView reloadData];
}
相关问题
- 1. 删除按钮不会出现在UITableViewCell
- 2. Unslide删除按钮的UITableViewCell
- 3. UITableViewCell,删除按钮框架?
- 4. 删除UITableViewCell无删除按钮?
- 5. UITableView删除按钮不出现
- 6. UITableViewCell刷卡,但没有出现删除按钮
- 7. 防止UITableViewCell左移,删除按钮出现在编辑表
- 8. 当“删除”按钮出现时,UITableViewCell重新组织子视图
- 9. 无法从UITableView中删除行(从不出现删除按钮)
- 10. UITableViewCell的自定义删除按钮
- 11. 如何从UITableViewCell中删除按钮?
- 12. 如何显示左删除按钮UITableViewCell
- 13. 将“删除”按钮添加到UITableViewCell
- 14. 更改默认删除按钮UITableViewCell
- 15. UITableViewCell的删除按钮动画
- 16. 向UiTableViewCell添加一个删除按钮
- 17. jQuery Javascript HTML 5导出按钮不会出现并删除其他按钮
- 18. 当出现删除按钮时重新计算自定义UITableViewCell的高度
- 19. 单击自定义删除按钮时删除UITableViewCell
- 20. 如何在编辑UITableViewCell时删除删除按钮?
- 21. 自定义UITableViewCell删除按钮不显示
- 22. UITableViewCell,显示轻扫式删除按钮,不用刷卡
- 23. UITableViewCell子类:删除并重新排序按钮不显示
- 24. 按钮不出现
- 25. TTLauncherView删除删除按钮
- 26. 删除按钮不工作
- 27. 删除按钮
- 28. 删除按钮
- 29. 删除按钮
- 30. 删除按钮
我终于明白了这一点。我选择了这个答案,因为所有你需要做的就是实现这两个方法,它的工作原理。我已经实现了这两种方法,但删除按钮被隐藏在JASidePanel的中心面板控制器下面...我只需要缩小tableview的宽度就可以了。 – AFraser 2013-03-18 15:05:42
@AFraser - 实际上,您的评论帮助我回答了我的问题自己的问题,因为我的问题非常相似(主视图(在自定义拆分视图控制器中)的右侧被详细视图遮挡)。我肯定会建议把它作为答案,因为你的问题确实提到了JASidePanel控制器。 – Animal451 2014-02-05 08:21:19