0

I make custom delete button for my TableViewCell with this method :

- (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???

user3797431
  • 393
  • 1
  • 5
  • 15
  • http://stackoverflow.com/questions/19164188/custom-edit-view-in-uitableviewcell-while-swipe-left. Dude check the link.I hope this is what u want to look – vishnuvarthan Aug 11 '14 at 07:20

2 Answers2

0

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;
}
Kumar KL
  • 15,315
  • 9
  • 38
  • 60
  • my friend when I do this code my cell not moving. how to moving and Appearance my custom button??? – user3797431 Aug 11 '14 at 07:01
  • What you need exactly? Is that you need to edit the cell(swipe) - your custom delete btw instead of default delete btw?? – Kumar KL Aug 11 '14 at 07:03
  • my friend I want edit the cell (swipe) another meaning : I want when swipe to left on my cell show my custom button delete for delete my cell!!! – user3797431 Aug 11 '14 at 07:05
  • Instead of adding your own delete btn, try this **http://stackoverflow.com/questions/1615469/custom-delete-button-on-editing-in-uitableview-cell** – Kumar KL Aug 11 '14 at 07:09
  • my friend I want make custom button with custom font this post no good for me please guide me more. – user3797431 Aug 11 '14 at 07:12
0

Implement the tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath method and return NO inside the delegate method.

Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156