0

I have a button that triggers [sppvc setEditing:!sppvc.isEditing animated:YES]; and the delete symbols come up but nothing happens when you click them(they dont rotate nor does the delete button show like it does when you slide to delete), also they dont slide things over when they appear. I should mention sliding to delete works fine.

Heres a picture to explain what I mean:

enter image description here

UPDATE: holding the red delete symbol / sign and letting go after a couple of seconds causes the delete button to come up. how can I make this instant.

BluGeni
  • 3,378
  • 8
  • 36
  • 64
  • Set your imageview.userinteractionEnabled = YES; – Midhun MP Jun 11 '13 at 13:35
  • where would I do this? I have a prototype cells and i tried doing it in the cells class but that didnt change anything. – BluGeni Jun 11 '13 at 13:47
  • you don't have to hold red circle button for a while. when you touch it the delete button automatically comes – iEinstein Jun 11 '13 at 14:01
  • @AshutoshMishra Mishra I know that is how it is suppose to work but in my case if I tap the button nothing happens, only if I hold it for exactly 2-3 then let go the delete button will come up. I dont understand why though. – BluGeni Jun 11 '13 at 14:11
  • I have given the answer please check – iEinstein Jun 11 '13 at 14:33

4 Answers4

1

You need to implement the below code.Its the delegate methods of UItableview which called automatically whenever you swipe a cell for deletion

    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return YES if you want the specified item to be editable.
    return YES;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        //add code here for when you hit delete

}
}
Rohit Pathak
  • 359
  • 4
  • 16
  • I have both of these methods with logs to make sure they are being hit, I just found that if i hold the delete symbol/sign for a couple seconds then release i get he delete button to come up. why is this happening? – BluGeni Jun 11 '13 at 13:57
0

Please use this code and tell me if it is working or not.

-(void)editButtonPressed:(id)sender
{
    if(self.editing)
    {
        [super setEditing:NO animated:YES]; 
        [selectSongTableView setEditing:NO animated:YES];
        [self.navigationItem.leftBarButtonItem setTitle:@"Edit"];
        [self.navigationItem.leftBarButtonItem setStyle:UIBarButtonItemStylePlain];

    }
    else
    {

        [super setEditing:YES animated:YES]; 
        [selectSongTableView setEditing:YES animated:YES];
        [self.navigationItem.leftBarButtonItem setTitle:@"Done"];
        [self.navigationItem.leftBarButtonItem setStyle:UIBarButtonItemStyleDone];

    }  

}

Please use this code if you are performing editing in UITableView on tapping of any button. Use the table name of your own.

Hope this helps otherwise I am here.

iEinstein
  • 2,100
  • 1
  • 21
  • 32
0

That behavior is not accessible via code-it should be automatic. Is this a device or the emulator your are using? What you are describing sounds like there is something wrong with the way the touchdown event is being handled by the device/emulator, i.e. something outside your application. I would try running the app on another device, if you haven't already done so.

The other possibility is that, based on the image you provided, it looks like the delete button is overlying an image on your tableviewcell. Whenever the delete symbol presents itself, your entire cell should indent, including whatever images are inside it. This implies that the image is somehow recognized as being outside of your tableviewcell and thus may be interfering with the touch event. So it may be an issue with how you have created your tableviewcells(i am assuming they are customized) and the imageviews inside them. And a final, simple thing I have overlooked myself in the past. Make sure the User Interaction Enabled box is checked in your cell nib file.

jeremyw
  • 111
  • 4
  • In my answer I explain what happened and why it was acting like that. I dont fully understand it but its fixed at least! – BluGeni Jun 11 '13 at 14:40
0

Turns out

UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
    [self.tableView addGestureRecognizer:gestureRecognizer];

creates this 3 second delay for the delete symbol to be activated. Hope this helps someone out.

This question helps fix that problem

UIButton inside a view that has a UITapGestureRecognizer

Community
  • 1
  • 1
BluGeni
  • 3,378
  • 8
  • 36
  • 64