Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8918721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:49:27+00:00 2026-06-15T05:49:27+00:00

Possible Duplicate: Replace action of swipe to delete by clicking on a button I

  • 0

Possible Duplicate:
Replace action of swipe to delete by clicking on a button

I have the following code.

- (void) tableView: (UITableView *) tableView commitEditingStyle: (UITableViewCellEditingStyle) editingStyle forRowAtIndexPath: (NSIndexPath *) indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [appointments removeObjectAtIndex: indexPath.row];  // manipulate your data structure.
        [tableView deleteRowsAtIndexPaths: [NSArray arrayWithObject: indexPath]
                         withRowAnimation: UITableViewRowAnimationFade];
       NSLog(@"row deleted");  // Do whatever other UI updating you need to do.
    }
} 

This piece of code is going to be execute when I swipe on the cell. But what I want is that this code executes when I press a button in my custom tableview cell. Like you can see on the screenshot below I have 2 buttons on my tableview.

enter image description here

When the user presses the ‘X’ button the delete button should roll out like when you swipe the cell. I have the following action attached to my cell.

-(IBAction) deleteAppointment:(id) sender{
   //show swipe delete button
}

And attached it in my cellForRowAtIndex at the following way.

cell.deleteAppointment.tag = indexPath.row;
[cell.deleteAppointment addTarget:self action:@selector(deleteAppointment:) forControlEvents:UIControlEventTouchUpInside];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:49:28+00:00Added an answer on June 15, 2026 at 5:49 am

    just addTarget with button in your cell and set tag to every button like bellow..

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        /////your code
        UIButton *btnClose = [[UIButton alloc]initWithFrame:CGRectMake(270, 7, 20, 20)];
        btnClose.tag = indexPath.row;
        [btnClose setImage:[UIImage imageNamed:@"closeImage.png"] forState:UIControlStateNormal];
        [btnClose addTarget:self action:@selector(deleteAppointment:) forControlEvents:UIControlStateNormal];
        [cell addSubview:btnClose];
        return cell;
    }
    

    and in the method see like this…

        - (IBAction)deleteAppointment:(id)sender {
    
                // here bellow code for swipe the close button in cell
                UIButton *btn = (UIButton *)sender;
                int SelectedRowNo = btn.tag;
                [UIView beginAnimations:nil context:NULL];
                [UIView setAnimationDuration:0.3];
                [btn setFrame:CGRectMake(btn.frame.origin.x - 50, btn.frame.origin.y, btn.frame.size.width, btn.frame.size.height)];
                [UIView commitAnimations];
    
                //// here bellow code for delete raw from table
                /*
                 [appointments removeObjectAtIndex: SelectedRowNo];
                 UITableViewCell *clickedCell = (UITableViewCell *)[[sender superview] superview];
                 NSIndexPath *clickedButtonPath = [yourTableView indexPathForCell:clickedCell];
                 [yourTableView deleteRowsAtIndexPaths: [NSArray arrayWithObject: clickedButtonPath]
                 withRowAnimation: UITableViewRowAnimationFade];
                 NSLog(@"row deleted");  // Do whatever other UI updating you need to do.
                 */
    }
    

    i hope this help you..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Replace individual list elements in Haskell? I have managed to make some
Possible Duplicate: Preg Replace - replace second occurance of a match I have a
Possible Duplicate: Why does javascript replace only first instance when using replace? I have
Possible Duplicate: Replace while keeping certain words in vi/vim Let's say I have several
Possible Duplicate: Replace only first match using preg_replace I have a string as follows:
Possible Duplicate: replace all occurrences in a string I have this string: 12-3-02 And
Possible Duplicate: JavaScript replace all / with \ in a string? I have a
Possible Duplicate: How to replace string in SQLite? I have a table column data
Possible Duplicate: Search and Replace Entire Project (Netbeans) Other IDE's have a feature to
Possible Duplicate: Use slashes in sed replace I need to find the following string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.