Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView reloadData does not cause table cells to show new data
    primarykey
    data
    text
    <p>When I update my data structures that fuel the UITableView, I call reladData. However, when I present my UITableView, the new values are not shown. Only the first time, the values are shown. Subsequently, when the new values are updated, the UITableView shows the old values still. I do not see the cellForRowAtIndexPath getting called. How do I get my new data to show?</p> <p>Here is the code:</p> <pre><code>@implementation MyViewController @synthesize tableView; @synthesize maxEntries, selectedIndex; @dynamic names, quotes; // used pressed the "Done" button - (IBAction)done { selectedIndex = -1; [self dismissModalViewControllerAnimated:YES]; } - (void)viewWillAppear:(BOOL)animated { selectedIndex = -1; [tableView reloadData]; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return maxEntries; } - (int)getSelectedIndex { return selectedIndex; } - (void)resetSelectedIndex { selectedIndex = -1; } - (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath { selectedIndex = indexPath.row; [self dismissModalViewControllerAnimated:YES]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *kPlacemarkCellID = @"GrapeCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kPlacemarkCellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kPlacemarkCellID] autorelease]; } CGRect frame = cell.textLabel.frame; frame.size.width = 200; cell.textLabel.frame = frame; if ((int)indexPath.row &lt; maxEntries) { if (names[indexPath.row] != nil) { cell.detailTextLabel.text = names[indexPath.row]; } else { cell.textLabel.text = @"..."; } if (quotes[indexPath.row] != nil) { cell.textLabel.text = quotes[indexPath.row]; } else { cell.detailTextLabel.text = @"..."; } } else { cell.textLabel.text = @""; cell.detailTextLabel.text = @""; } return cell; } - (void)addEntry: (NSString *)name withQuote:(NSString *)quote { if (maxEntries &lt; MAX_ENTRIES) { names[maxEntries] = [name copy]; quotes[maxEntries] = [quote copy]; maxEntries++; [tableView reloadData]; } } - (void) clearEntries { maxEntries = 0; selectedIndex = -1; [tableView reloadData]; } - (void)viewDidUnload { self.tableView = nil; } - (void)dealloc { [tableView release]; [super dealloc]; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload