[英]Trigger UITableViewCellEditingStyleDelete when button inside tableview cell is tapped
这是我的单元格,当我点击单元格左侧的图标时,它会触发,就像用户滑动该单元格一样。
我有UITableViewCell的子类,也连接了icon(button)。 看起来像这样
- (IBAction)didPressMinusButton:(id)sender {
[self setEditing:YES animated:YES];
}
在我的tableView中我也有这个
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
//my code for deletion here
}
当用户点击我的单元格左侧的图标时,我想实现显示删除或删除的功能。 基本上就像滑动,但在这种情况下,我只是通过点击触发它。
您的意思是,当用户点击左侧的减号图标时,删除功能应该起作用而不是滑动。
如果是,则只需删除此代码或为此添加注释
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
//my code for deletion here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.