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

  • Home
  • SEARCH
  • 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 6069357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:48:51+00:00 2026-05-23T09:48:51+00:00

I have a UIButton within a custom UITableViewCell . I added this button in

  • 0

I have a UIButton within a custom UITableViewCell. I added this button in Interface Builder.

I then use the following code within cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"GenericCellButton";

    GenericCellButton *cell = (GenericCellButton *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:nil options:nil];

        for (id currentObject in topLevelObjects) {
            if ([currentObject isKindOfClass:[UITableViewCell class]]) {
                cell = (GenericCellButton *)currentObject;
                break;
            }
        }
    }

    [cell.inviteButton addTarget:self action:@selector(inviteButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
    [cell.inviteButton setTag:indexPath.row];

    // This statement doesn't get called...?
    if ([cell.inviteButton.titleLabel.text isEqualToString:@"Please Wait"]) {
        [cell.inviteButton setEnabled:NO];
        [cell.inviteButton setTitle:@"Please Wait" forState:UIControlStateDisabled];
    }
  ...

This is the followTapped: method:

- (void)followTapped:(id)sender {
    UIButton *button = (UIButton *)sender;
    [button setEnabled:NO];
    [button setTitle:@"Please Wait" forState:UIControlStateDisabled];

    // I then call a service method that then fires off a callback method that refreshes the `tableView`. This changes the button text to "Following".
}

Everything is working just fine in terms of saving the record.

The problem is that before the callback method is fired; if the user scrolls the visible cell out of view before the tableView is refreshed, it’s resetting the button back to “Follow” instead of “Please Wait”, which means if they tap the “Follow” button again it causes issues in my database.

How can I stop that particular cell from refreshing before the tableView is reloaded if it is scrolled out of view? I tried adding some logic in the cellForRowAtIndexPath: that checks for whether the button text is “Please Wait”, but it doesn’t seem to be working as expected. It’s still resetting back to “Follow”.

  • 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-23T09:48:52+00:00Added an answer on May 23, 2026 at 9:48 am
    - (void)followTapped:(id)sender 
    {
    UIButton *button = (UIButton *)sender;
    [button setEnabled:NO];
    [button setTitle:@"Please Wait" forState:UIControlStateDisabled];
    
    selectedIndex = indexPath.row; //create this variable in .h file 
    
    // I then call a service method that then fires off a callback method that refreshes the `tableView`. This changes the button text to "Following".
     }
    

    Now

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"GenericCellButton";
    
    GenericCellButton *cell = (GenericCellButton *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:nil options:nil];
    
        for (id currentObject in topLevelObjects) {
            if ([currentObject isKindOfClass:[UITableViewCell class]]) {
                cell = (GenericCellButton *)currentObject;
                break;
            }
        }
    }
    
    [cell.inviteButton addTarget:self action:@selector(inviteButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
    [cell.inviteButton setTag:indexPath.row];
    
    // This statement doesn't get called...?
    if (selectedIndex == indexPath.row)
    {
        [cell.inviteButton setEnabled:NO];
        [cell.inviteButton setTitle:@"Please Wait" forState:UIControlStateDisabled];
    }
    

    …

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

Sidebar

Related Questions

I have created a custom UIButton (UIButton subclass) for my application. Within this button's
I have the following example class: Test.h: @interface Test : UIButton { NSString *value;
I created a custom UItableviewcell added a button into its initWithStyle area: favoriteButton =
I have a bunch of custom UITableCells that I have built in interface builder.
I have a UIButton within a UIView. The button is docked on the bottom
I have a very simply subclass of UIButton that will fire off a custom
I want to have a button on a screen with this image. this image
Assuming I have created a 2DArray of buttons using the following code: for (NSInteger
Suppose I have a method like this - (UIButton *) createButtonAtX:(CGFloat)vX Y:(CGFloat)vY{ //... bla
I have a UIButton that is added to a UIImageView (it's a big chart)

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.