[英]how to hide default delete button tableviewcell
I make custom delete button for my TableViewCell
with this method : 我使用以下方法为
TableViewCell
制作了自定义删除按钮:
- (void)willTransitionToState:(UITableViewCellStateMask)state
{
[super willTransitionToState:state];
if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask)
{
for (UIView *subview in self.subviews)
{
NSLog(@"%@",NSStringFromClass([subview class]));
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellScrollView"])
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(aMethod:)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"remove" forState:UIControlStateNormal];
[button setBackgroundColor:[UIColor yellowColor]];
button.frame = CGRectMake(320, 0, 85.0, 60.0);
[[subview.subviews objectAtIndex:0] addSubview:button];
}
}
}
}
I have one problem. 我有一个问题。 I want my custom button (top button) put instead default delete button.
我希望将自定义按钮(顶部按钮)放到默认的删除按钮中。 Now when I swipe my cell show two delete button (first default button & second my custom button) how to hide default delete button???
现在,当我滑动单元格时,将显示两个删除按钮(第一个默认按钮和第二个自定义按钮)如何隐藏默认的删除按钮???
Now when I swipe my cell show two delete button (first default button & second my custom button) how to hide default delete button???
现在,当我滑动单元格时,将显示两个删除按钮(第一个默认按钮和第二个自定义按钮)如何隐藏默认的删除按钮???
Override to support conditional editing of the table view cell. 重写以支持表视图单元格的条件编辑。
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return NO;
}
实现tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
方法,并在委托方法内返回NO
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.