Does tableViewController behave incorrectly when hosted by a popoverController?

Posted by dugla on Stack Overflow See other posts from Stack Overflow or by dugla
Published on 2010-06-15T23:09:25Z Indexed on 2010/06/15 23:12 UTC
Read the original article Hit count: 218

I have made countless test examples of a tableViewController hosted by a popoverController and I have come to the following conclusion: It does not appear possible to pre-select a tableView cell.

It is possible to do pre-selection when a tableViewController is hosted by a splitviewController.

I am using the exact same tableViewController code. Here is the relevant tableViewController view lifecycle method that is misbehaving:

static BOOL firstTime = YES;
- (void)viewDidAppear:(BOOL)animated {

    NSLog(@"Root ViewController - view Did Appear");

    [super viewDidAppear:animated];

    if (firstTime == YES) {

        firstTime = NO;

        NSIndexPath *preselectedCell = [NSIndexPath indexPathForRow:5 inSection:0];
        [self.tableView selectRowAtIndexPath:preselectedCell 
                                    animated:NO 
                              scrollPosition:UITableViewScrollPositionTop];

        detailViewController.detailItem = 
        [NSString stringWithFormat:@"Row %d", preselectedCell.row];

    } // if (firstTime == YES)

}

The above code correctly preselects a tableView cell the first time the tableView is unfurled in the splitViewController case (device in portrait mode).

Can someone please, please, explain what I am doing wrong. I am completely stumped.

Thanks,
Doug

© Stack Overflow or respective owner

Related posts about ipad

Related posts about uitableviewcontroller