views:

55

answers:

1

Hello stackoverflow,

So I have been searching everywhere for a solution to this problem. I have a table view that displays a popover from a cell when the user selects it. However there is a bug but I can't figure out a solution. Basically once you scroll down off the first page of results, the popover always appears from the bottom of the screen instead of the selected table cell. The reason for this is I am creating the popover from the cell rectangle via:

CGRect cellRect = [tableView rectForRowAtIndexPath:indexPath];

self.detailController.contentSizeForViewInPopover = CGSizeMake(cellRect.size.width, 350);   
self.personDetailPopoverController = [[[UIPopoverController alloc] initWithContentViewController:self.detailController] autorelease];

[self.personDetailPopoverController presentPopoverFromRect:cellRect
                                        inView:self.view
                      permittedArrowDirections:UIPopoverArrowDirectionAny
                                      animated:YES];

This works great for the first 8 rows (my cells are 100 units tall), but causes that problem noted above because it is trying to display it at y=1400 (for the 14th cell, etc). Does anyone know of a better way to display the popover from the selected cell? Perhaps a creative use of touches? Any feedback would be greatly appreciated. Thanks!

A: 

You need to convert your rectangle to your view's coordinate system:

[self.view convertRect:cellRect fromView:tableView];
David M.
That didn't work. Do I need to apply it to the detail controller? Or something else?
Geoff Baum
Sorry, went back and read the documentation. I wasn't saving it in a new rectangle. Thanks!
Geoff Baum
Getting a firm handle on UIView's `frame` and `bounds` and coordinate systems will save you a lot of headaches over the long run. Best of luck.
David M.