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 6766179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:47:56+00:00 2026-05-26T14:47:56+00:00

I have an UIButton in a UITableViewCell of an UITableView. The UIButton is hidden.

  • 0

I have an UIButton in a UITableViewCell of an UITableView. The UIButton is hidden. When the user swipes left with his finger on a specific UITableViewCell the button show up.

I use this code to implement it and it is working but the button shows up in more than one uitableviewcells other than the one that the user swiped his finger!

- (void)cellSwiped:(UIGestureRecognizer *)gestureRecognizer 
{
    if (gestureRecognizer.state == UIGestureRecognizerStateEnded) 
    {
        UIView *tappedview=[gestureRecognizer.view hitTest:[gestureRecognizer locationInView:gestureRecognizer.view] withEvent:nil];

        UIView *contentview1=tappedview.superview;
        UIView *viewwithtag4=[contentview1 viewWithTag:7009];
        UIButton *button2=(UIButton *)viewwithtag4;

        NSLog(@"swipe left detected");

        [button2 setHidden:FALSE];
    }
}

Any help appreciated! Thanks.

  • 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-05-26T14:47:57+00:00Added an answer on May 26, 2026 at 2:47 pm

    if the button is showing up in the wrong cells after scrolling it is because the tableCells are being reused by the tableView in order to enhance performance. i.e.

    If you want to keep the button visible for a particular cell, you will have to do the following:

    In the method that is called by the gestureRecognizer save the button’s state. You will have to determine the cell that has been swiped, then save that state probably in the class/model that your are filling the cell with. i.e your data source. For example, if your data source is an object in an array you could do something along the lines

    // in your cellSwiped method and assuming you can traverse the view hierarchy to get
    // the tableViewCell.
    NSIndexPath *theCellIndexPath=[self.tableView indexPathForCell: theTableViewCell];
    MyDataSourceObject *theDataSourceObject=[dataObjectArray objectAtIndex: theCellIndexPath.row];
    // The buttonIsVisible ivar for your data source could be name that
    // or something else that is meaningful.  Not sure what the button i
    // related to in you objects
    theDataSourceObject.buttonIsVisible=YES  // or you could put in code to toggle the value
    

    Then in your cellForRowAtIndexPath method, you will have to set the button to be hidden or not depending on the state for that particular indexPath.

    MyDataSourceObject *theDataSourceObject=[dataObjectArray objectAtIndex: indexPath.row];
    cell.button.hidden=theDataSourceObject.buttonIsVisible;
    
    return cell;
    

    Good luck

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

Sidebar

Related Questions

I have a UIButton in my UITableViewCell . This button launches a UIActionSheet so
I have a subclassed UIButton inside a subclassed UITableViewCell . The button is loaded
I have a UIButton inside a UITableViewCell . When the user touches a cell's
I have a UIButton in a UITableView cell, in a UITableView. The result is
I have a custom UITableViewCell which contains several UIButtons. Each button's frame position is
I have UIButton in each cell of UITableView . When I touch it, its
I have a UITableView with 5 UITableViewCells . Each cell contains a UIButton which
I have successfully implemented a UITextField in a UITableViewCell. Just like this: . I
I have this code below to populate my UITableView on the fly. I have
I have implemented the accessory view of a UITableViewCell as a button, in the

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.