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.
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.
}
}
Use commitEditingStyle
ie
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
Take care of this method
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.