views:

290

answers:

1

Hi,

I would like to present an UIPopover from an UITableView specific index. Here's my code:

if (indexPath.row == 5) {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    EnginesPopoverController  *enginesPopoverController = [[EnginesPopoverController alloc] initWithNibName:@"EnginesPopoverController" bundle:nil];

    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:enginesPopoverController];

    self.popoverController = popover;
    popoverController.delegate = self;

    [popover release];
    [enginesPopoverController release];

    CGPoint point = {670, 600};
    CGSize size = {450, 216};

    [popoverController presentPopoverFromRect:CGRectMake(point.x, point.y, size.width, size.height) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];                 
}

If I try to present the Popover from an UIButton it goes well...

Thanks!

A: 

This is what I do:

CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath]; 
CGRect popoverRect = CGRectMake(self.view.bounds.size.width - self.popoverController.popoverContentSize.width,
                                CGRectGetMidY(cellRect),
                                1.0, 1.0);

The x location I use places the popover on the right-hand side of the screen. This may not be what you want. To find the actual touch point, you can use gesture recognizers.

In return, please try to answer my related question: http://stackoverflow.com/questions/3442953/popovers-arrow-to-track-an-object-in-a-scrollview

David M.