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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:30:02+00:00 2026-05-27T11:30:02+00:00

I have a UIButton in my UITableViewCell . This button launches a UIActionSheet so

  • 0

I have a UIButton in my UITableViewCell. This button launches a UIActionSheet so when a user pics a button from the action sheet, I want the text of the button to change to that text.

I show the button with the following code. I think if I call ‘tableView reload’ in actionSheet: clickedButtonAtIndex: would work but is there a better alternative to just update the statusButton?

SmokingStatusTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.statusButton.titleLabel.text = [self.vitalsDictionary objectForKey:@"smoking_status_display"];


- (IBAction)smokingStatusButtonClicked:(id)sender{
    UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Smoking Status" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"1 Current everday smoker", @"2 Current some day smoker", nil];
    self.smokingStatusActionSheet = actionSheet;
    [self.smokingStatusActionSheet showInView:self.view];
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{    
    if (actionSheet == self.smokingStatusActionSheet){
        switch (buttonIndex) {
            case 0:
                [self.vitalsDictionary setObject:@"daily_smoker" forKey:@"smoking_status"];
                break;
            case 1:
                [self.vitalsDictionary setObject:@"nondaily_smoker" forKey:@"smoking_status"];
                break;
            default:
                break;
        }
    }
}
  • 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-27T11:30:03+00:00Added an answer on May 27, 2026 at 11:30 am

    You should update your data source and then you can potentially reconfigure the cell again if required.

    If the cell is off screen then it should automatically be updated in your implementation of tableView:cellForRowAtIndexPath: when it becomes visible again.

    If you want to force it to update and it is visible you can:

    1. Call reloadData

    2. Call reloadRowsAtIndexPaths:withRowAnimation:

    3. Call cellForRowAtIndexPath: and configure it.

    For 2 + 3 you will need to keep a reference to the indexPath of the cell that invoked the action sheet.

    If you choose 3 it may help to have your tableView:cellForRowAtIndexPath: method set up like so:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
    
        [self configureCell:cell atIndexPath:indexPath];
    
        return cell;
    }
    
    - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
    {
        //..configure label etc here
    }
    

    By separating out configureCell:atIndexPath: you can use the same code to configure the cell.

    For example you may call

    -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
    {    
        if (actionSheet == self.smokingStatusActionSheet){
            switch (buttonIndex) {
                case 0:
                    [self.vitalsDictionary setObject:@"daily_smoker" forKey:@"smoking_status"];
                    break;
                case 1:
                    [self.vitalsDictionary setObject:@"nondaily_smoker" forKey:@"smoking_status"];
                    break;
                default:
                    break;
            }
        }
    
        NSIndexPath *indexPath = self.selectIndex;
        UITableViewCell *cell = [self.tableView cellForRowAtPath:indexPath];
        [self configureCell:cell atIndexPath:indexPath];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a button action method. Initialized an NSDictionary with values from an
I want to have a UIButton in each UITableViewCell that will allow me to
I have a UIButton inside a UITableViewCell . When the user touches a cell's
I have a custom UITableViewCell which contains several UIButtons. Each button's frame position is
I have a UIButton that is created inside of each table cell. I want
I have an UIButton in a UITableViewCell of an UITableView. The UIButton is hidden.
I have successfully implemented a UITextField in a UITableViewCell. Just like this: . I
I have implemented the accessory view of a UITableViewCell as a button, in the
I have this code on my cellForRowAtindexPath, with a custom cell and a button
I have a UIButton in the UITableViewCell which i would like to toggle it's

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.