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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:46:41+00:00 2026-06-05T08:46:41+00:00

I have a view controller with many views and a tableview. The tableview’s cells

  • 0

I have a view controller with many views and a tableview.

The tableview’s cells are customized, so there is another class for setting up the cells.
In each cell there is a button. The image of this button changes depending on the cell’s content (this content gets read from a DB).

Basically, when the user presses the button, it changes itself to another image, a new status is written to the DB but the tableview does not update itself automatically.

The method for the button is in the custom cell class, so I’ve tried to instantiate my view controller (the one with the tableview) and execute a method for updating some labels in the views and the tableview:

ViewControllerWithTable *vc = [[ViewControllerWithTable alloc] init];
[vc updateEverything];

But this doesn’t work.
The same “updateEverything” method, called from the same “ViewControllerWithTable” (adding a reload button) works perfectly.
Adding the “[tableView reloadData]” in the viewWillAppear method won’t work because all the action is done in the same view.

What am I missing?

EDIT: adding some code to be more clear.

This is the method I use to update the tableview. It’s inside the ViewController with the embedded tableview and it works when triggered by a button in one of the views:

- (void) updateEverything {
    // lots of DB writing and reading, plus label text changing inside all the views
    [tableView reloadData];

}

This is the IBAction for the button press and it’s in the custom cell class:

-(void) btnPresaPressed:(UIButton *)sender {
    AppDelegate *deleg = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    deleg.did = sender.tag;
    NSString *s1 = NSLocalizedString(@"ALERT_TITLE", nil);
    NSString *s2 = NSLocalizedString(@"ALERT_BODY", nil);
    NSString *s3 = NSLocalizedString(@"YES", nil);
    NSString *s4 = NSLocalizedString(@"NO", nil);
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:s1
                                                        message:s2
                                                       delegate:self
                                              cancelButtonTitle:s4
                                              otherButtonTitles:s3, nil];
    [alertView setTag:1];
    [alertView show];

}

This method shows an alert view that calls another method, always in the custom cell class:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
    AppDelegate *deleg = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    DbOperations *db = [[DbOperations alloc] init];
    NSString *alrtTitle = [alertView buttonTitleAtIndex:buttonIndex];
    NSString *s3 = NSLocalizedString(@"YES", nil);
    NSString *s4 = NSLocalizedString(@"NO", nil);
    switch (alertView.tag) {
        case 1:
            //
            break;
        case 2:
            if ([alrtTitle isEqualToString:s3]) {
                // DB writing and reading
                ViewControllerWithTable *vc = [[ViewControllerWithTable alloc] init];
                [vc updateEverything];
            } else if ([alrtTitle isEqualToString:s4]){
                //

            }
            break;
        case 3:
            if ([alrtTitle isEqualToString:s3]) {
                //
            }
            break;
        default:
            break;
    }

}

In this case, the updateEverything method don’t work.

  • 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-05T08:46:43+00:00Added an answer on June 5, 2026 at 8:46 am

    EDIT after you added more code:

    In the following lines:

            if ([alrtTitle isEqualToString:s3]) {
                // DB writing and reading
                ViewControllerWithTable *vc = [[ViewControllerWithTable alloc] init];
                [vc updateEverything];
    

    you are instantiating a new view controller altogether that has nothing to do with your original view controller that displayed the table view. So, you are sending the update message to the wrong object.

    What you need is a mechanism for your cell to know which is the right controller to send the message to.

    One easy solution would be using NSNotificationCenter:

    1. the view controller register itself for a certain kind of notification:

      [[NSNotificationCenter defaultCenter]
      addObserver:self
      selector:@selector(updateEverything:)
      name:kCellSentUpdateMessageNotification
      object:nil];
      
    2. your cell sends the notification, instead of calling the message directly:

      [[NSNotificationCenter defaultCenter] postNotificationName:kCellSentUpdateMessageNotification object:nil];
      

    OLD Answer:

    You should call

      [self.tableView reloadData]
    

    from your updateEverything method implementation. This will reload the table data, effectively updating its rows appearance. The updateEverything method shall be called when tapping on the button in a row for this to work, obviously.

    If that does not work, please provide more code.

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

Sidebar

Related Questions

I have the problem that my view controller class has too many delegates and
I have a table view of custom cells representing individual uploads and each cell
I have a view controller with 6 buttons on it. Each of these buttons
I have an application that has many views (Using tab bar controller). I want
I have View Controller with a (navigation controller) that can flip between 2 views
I have 2 views controlled by a tab bar view controller created by the
I have view controller, into the view i have put a table view, and
i have view controller which contains a button which show the image library ,if
I have a view controller where I display a grid/array of images, where every
I have a view controller subclass of UIWebView . If I release that object

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.