1

Since didSelectRowAtIndexPath is fired on UITableViewCell selection, it must have a controlEvent like UIControlEventTouchUpInside (as an example). Which controlEvent is fired on calling didSelectRowAtIndexPath ?
The reason I am asking this is, my UITableViewCell has swipe buttons whose events are getting conflicted with didSelectRowAtIndexPath. But when I see the iPhone's default mail app, it works quite smooth.

Nitish
  • 13,845
  • 28
  • 135
  • 263
  • You will have to look through the cell's (or its contentView's) gesture recognizers to see what all gestures it handles. Once you find the tap gesture, you can use it to control which gesture gets fired when. There is also an iOS provided way to add the cell swipe feature that works really well; have you tried that? – keithbhunter Jul 14 '16 at 12:14
  • 1
    didSelectRowAtIndexPath - it is the delegate method of tableview by detault if you touch the cell in anywhere the delegate method will fire. `controlEvent` - inside the cell you have any one type of the UIElement (E.g UIButton, UIsegment, UISlider) , if we touch the particular element (not in the entire cell ) the action will be fire. – Anbu.Karthik Jul 14 '16 at 12:14
  • @keithbhunter : I am afraid I haven't. May I know that ? – Nitish Jul 14 '16 at 12:16
  • You will need to implement `tableView:editActionsForRowAtIndexPath:`, `tableView:canEditRowAtIndexPath:` and `tableView:commitEditingStyle:forRowAtIndexPath:` at a minimum. [Here is another SO post about this topic](http://stackoverflow.com/a/24540551/2162028). – keithbhunter Jul 14 '16 at 12:20
  • @keithbhunter : Yes, I am using these only. Still didSelectRowAtIndexPath is getting fired if I start the swipe and end it without releasing the finger in between. – Nitish Jul 14 '16 at 12:25

2 Answers2

0

You have to need implement delegate method for handling swipe event smoothly following are the some example-

- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Call" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){

        // maybe show an action sheet with more options

        // NSIndexPath *cellIndexPath = [self.tView indexPathForCell:cell];
        // UIActionSheet *shareActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Contact Info", @"Email Conversation",@"Clear Conversation", nil];
        // shareActionSheet.tag=indexPath.row;
        // [shareActionSheet showInView:self.view];


        [self callButtonClicked:conObject.userName];

        //[cell hideUtilityButtonsAnimated:YES];

        [self.tView setEditing:NO];

    }];

    moreAction.backgroundColor=[UIColor colorWithRed:77.0/255.0 green:216.0/255.0 blue:101.0/255.0 alpha:1];

    //  moreAction.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"MobileRingIcon"]];

    UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Delete"  handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){

        UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete"otherButtonTitles: nil];

        sheet.tag=indexPath.row;

        [sheet showInView:self.view];

    }];

    [deleteAction setBackgroundColor:[UIColor redColor]];

    return @[deleteAction, moreAction];
}

// From Master/Detail Xcode template
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {

    } else if (editingStyle == UITableViewCellEditingStyleInsert) {

        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
    }
}
Rohit Khandelwal
  • 1,778
  • 15
  • 23
Bhaskar
  • 51
  • 5
-1

Use commitEditingStyle i.e.

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

Take care of this method

Rohit Khandelwal
  • 1,778
  • 15
  • 23