Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate selection from second UITableView in original UITableView
    primarykey
    data
    text
    <p>I can't get my first UITableView to update with a setting made in a second UITableView.</p> <p>A user clicks a row in firstTableView causing secondTableView to be displayed. When the user selects a row, secondTableView disappears and firstTableView is reappears. However, the data isn't updated.</p> <p>I tried using the following in firstTableView:</p> <pre><code>- (void) viewWillAppear:(BOOL)animated { // (verified it's defenitely section 2, row 0 by logging it before and after...) // (also verified that the source data has been updated before viewWillAppear is called...) NSIndexPath *durPath = [NSIndexPath indexPathForRow:0 inSection:2]; NSArray *paths = [NSArray arrayWithObject:durPath]; [self.firstTableView reloadRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationNone]; // If I use some row animation, I can clearly see that the correct row is being animated, it's just not being updated. } </code></pre> <p>But the label does not update. Obviously I'm missing something. Both views are modal view controllers. </p> <p>Here's my cell construction:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [firstTableView dequeueReusableCellWithIdentifier:CellIdentifier]; UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(150.0, 15.0, 120.0, 17.0)]; myLabel.backgroundColor = [UIColor clearColor]; myLabel.font = [UIFont systemFontOfSize:14]; myLabel.textAlignment = UITextAlignmentLeft; static NSString* kConstants[] = {kOption0,kOption1,kOption2,kOption3,kOption4,kOption5,kOption6,kOption7,kOption8,kOption9,kOption10,nil}; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; if (indexPath.section == 2) { [cell addSubview:myLabel]; } } switch (indexPath.section) { case 0: // … deal with a bunch of UISwitches break; case 1: // … deal with section 1 stuff break; case 2: { NSLog(@"Verify that intType has in fact been changed here: %i, %@",intType, kConstants[intType]); // Even though intType and the constant string reflects the correct (updated) values when returning from secondTableView, myLabel.text does not change, ie: it's correct one line above, but not correct one line below. The myLabel.text is just not updating to the new value. myLabel.text = kConstants[intType]; cell.textLabel.text = @"Choose Some Value:"; cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; } break; case 3: // … deal with section 3 stuff break; } [myLabel release]; return cell; } </code></pre>
    singulars
    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.
 

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