Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is probably exactly what you are looking for. I developed this for one of my apps. Enjoy ! (if so please mark as answered) Also note that I'm using ARC, so no retain and release.</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { /* 1. First we get the indexPath from the prior priorSelectedRowInteger and priorSelectedSectionInteger ivars. Note: we could use a single indexPath ivar, but we separate them into row and section here for clarity. 2. Then we reset the selectedRowInteger ivar to the currently selected row. This must be done before any rows are reloaded. 3. Then we reload only the two rows at the concerned index paths, as we have captured the indexPath of the prior selected row and the method gives us the new one. We could just simply reload the table here with [self.tableView reloadData], but it would not be animated and not as smooth. */ NSIndexPath *priorSelectedIndexPath = [NSIndexPath indexPathForRow:priorSelectedRowInteger inSection: priorSelectedSectionInteger]; // Now that we have the priorSelectedIndexPath, we save the new one for the next round. self.priorSelectedRowInteger = indexPath.row; self.priorSelectedSectionInteger = indexPath.section; // For a changing tableView, check to make sure the priorIndexPath is still valid before trying to reload the prior row. // NSLog(@"priorSelectedIndexPath %@", priorSelectedIndexPath); if ((tableView.numberOfSections &gt;= priorSelectedIndexPath.section+1) &amp;&amp; ([tableView numberOfRowsInSection:priorSelectedIndexPath.section] &gt;= priorSelectedIndexPath.row+1)) { NSArray *thePriorIndexPathArray = [NSArray arrayWithObject:priorSelectedIndexPath]; [self.tableView reloadRowsAtIndexPaths:thePriorIndexPathArray withRowAnimation:UITableViewRowAnimationFade]; } // Reload only the selected indexPath - necessary to update the text colors etc. NSArray *theIndexPathArray = [NSArray arrayWithObject:indexPath]; [self.tableView reloadRowsAtIndexPaths:theIndexPathArray withRowAnimation:UITableViewRowAnimationFade]; } </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.
    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