[英]Show Delete Button in Tableview in ios
I added a button as subview in TableViewCell. 我在TableViewCell中添加了一个按钮作为子视图。 When this button pressed, I need to show the Delete Button(right side) same as when we swipe the row.
按下此按钮时,我需要显示“删除按钮”(右侧),与滑动行时相同。 I don't want to show small delete button(left side).
我不想显示小的删除按钮(左侧)。 I need to implement same function when we press small delete button(left side), Big delete button display(right side).
当我按下小删除按钮(左侧),大删除按钮显示(右侧)时,我需要实现相同的功能。
my code 我的代码
-(IBAction)act_press
{
[tblArticles setEditing:YES animated:YES];
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//do delete stuff
}
}
How can I do this? 我怎样才能做到这一点?
You need to set UITableViewCell style for that indexPath 您需要为该indexPath设置UITableViewCell样式
- (void)willTransitionToState:(UITableViewCellStateMask)state{
[super willTransitionToState:state];
if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) {
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
// remove or hide the left small view
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.