On iPad, I show UIPopoverwhen the user selects cells in UITableView. The cell remains selected until the popover is rejected.
When the user rotates the device from portrait to landscape orientation, and the selected cell is at the bottom of the screen, it disappears after the rotation, and the popover ends, pointing to another (indifferent) cell.
How can I make sure that the selected cell in UITableViewremains on the screen when I rotate from portrait to landscape?
Update: Combining the Caleb and kviksilver codes, the following working solution:
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
CGRect activeCellRect = [self.tableView rectForRowAtIndexPath:self.indexPath];
if ((activeCellRect.origin.y + activeCellRect.size.height) >
(self.view.frame.origin.y + self.view.frame.size.height))
{
[self.tableView scrollToRowAtIndexPath:self.indexPath
atScrollPosition:UITableViewScrollPositionBottom
animated:YES];
}
}
2 UIPopover:. reloadData . rectForRowAtIndexPath: ( , )!