Search Results

Search found 1 results on 1 pages for 'bschlenk'.

Page 1/1 | 1 

  • UITableView insertRowsAtIndexPaths out of order

    - by bschlenk
    I currently have a UISegmentedControl set to add/remove table view cells when its value changes. Removing cells works perfectly, however when I insert cells they're in reverse order every other time. NSArray *addindexes = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:2 inSection:0], [NSIndexPath indexPathForRow:3 inSection:0], [NSIndexPath indexPathForRow:4 inSection:0], nil]; NSArray *removeindexes = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:2 inSection:0], [NSIndexPath indexPathForRow:3 inSection:0], [NSIndexPath indexPathForRow:4 inSection:0], nil]; [self.tableView beginUpdates]; switch (switchType.selectedSegmentIndex) { case 0: [self.tableView insertRowsAtIndexPaths:addindexes withRowAnimation:UITableViewRowAnimationTop]; break; case 1: [self.tableView deleteRowsAtIndexPaths:removeindexes withRowAnimation:UITableViewRowAnimationTop]; break; default: break; } [self.tableView endUpdates];} For example, every other time I add/remove cells they're in reverse order. (4, 3, 2 instead of 2, 3, 4) 1) Remove cells- add cells- correct order 2) Remove cells- add cells- incorrect order 3) Remove cells- add cells- correct order

    Read the article

1