Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved similar problem. I inserted item to beginning of Table and I wanted to select it just right after.</p> <p>Step 1. - Create a switch to keep state if it shall select first row</p> <pre><code>@implementation MyTableViewController { BOOL _selectFirstRow; } </code></pre> <p>Step 2. - Switch it to YES while inserting</p> <pre><code>- (void) controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { UITableView *tableView = self.tableView; switch (type) { case NSFetchedResultsChangeInsert: [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; _selectFirstRow = YES; break; </code></pre> <p>Step 3. - Create a method to select first row</p> <pre><code>- (void) selectFirstTableRow { [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop]; } </code></pre> <p>Step 4. - Call the method to select row right after table is updated</p> <pre><code>- (void) controllerDidChangeContent:(NSFetchedResultsController *)controller { [self.tableView endUpdates]; if (_selectFirstRow) { [self selectFirstTableRow]; _selectFirstRow = NO; } } </code></pre> <p>That's all folks .. if you want select different row, store newIndexPath in class parameter too. That's all. I hope it will help you. Cia!</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.
    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