Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView reloadData not displaying correctly after deleting row
    primarykey
    data
    text
    <p>I have this code for a UITableView with two columns I found online. It works fine whenever I add another row to it, but when I pick a row to delete it just deletes the last row instead. I just add rows to the bottom of the array with [NSMutableArray addObject:], but when I delete a row I select the row to be removed first.</p> <p>here is selecting the row ------( I checked to make sure tableViewIdx was correct)</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ tableViewIdx = [indexPath row]; } </code></pre> <p>then the delete button ------( I checked to make sure the object was actually removed from the array)</p> <pre><code>-(IBAction)bt_DeletePressed:(id)sender{ [mutableArray removeObjectAtIndex:tableViewIdx]; //delete actual content for(int i = VStableViewIdx;i&lt;10;i++){ g_vitals[i] = g_vitals[i+1]; } [TableView reloadData]; tableViewIdx--; } </code></pre> <p>and some of the tableView code</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ int count = [listData count]; if(self.editing) count++; tableSize = count; return count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row]; MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil){ cell = [[[MyTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"HH:mm"]; UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0, 60.00,tableView.rowHeight)] autorelease]; [cell addColumn:60]; label.font = [UIFont systemFontOfSize:12.0]; label.text = textView.text; [formatter release]; label.textAlignment = UITextAlignmentRight; label.textColor = [UIColor blueColor]; label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:label]; label = [[[UILabel alloc] initWithFrame:CGRectMake(70.0, 0, 60.0,tableView.rowHeight)] autorelease]; [cell addColumn:500]; label.font = [UIFont systemFontOfSize:12.0]; label.text = [NSString stringWithFormat:@"%d",respRateTemp]; label.textAlignment = UITextAlignmentRight; label.textColor = [UIColor blueColor]; label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:label]; } return cell; } </code></pre> <p>Any ideas why it would be removing the last row, instead of the selected one?</p> <p>EDIT: I was actually able to fix it myself, by using deleteRowsAtIndexPaths: instead of updateData, however now I have another problem. My program runs fine on the simulator, but crashes frequently on a device. It comes up with the error:</p> <p>Program received signal: "EXC_BAD_ACCESS".</p> <p>Data Formatters temporarily unavailable, will re-try after a 'continue'. (Can't find dlopen function, so it is not possible to load shared libraries.)</p>
    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