PDA

View Full Version : Coordinate transformation between Popover and background view




RonC
Aug 10, 2011, 03:24 PM
I'd like to present a Popover such that the arrow points a specific row selected in a tableview. The tableview is presented in popover, as it's the root view of a split view. I've attached a picture showing the interesting part of the upper left corner of the screen when it's in portrait mode. (I took that screen capture when stopped in the debugger in the tableView:didSelectRowAtIndexPath: method)
298451

What I'd like to have happen is the arrow of a new popover point at the vertical center of that row. I get the rectangle for the row using rectForRowAtIndexPath: and based on this screenshot I'm getting the correct rectangle (based on the orange wireframe rectangle - I wrote a little UIView subclass that draws that content based on it's frame, and I added an instance of that class as a subview to the tableview using the rectForRowAtIndexPath result as it's frame). For sake of discussion, that orange rectangle is {{0, 256}, {320, 46}}, and it's clearly in the coordinate system of the tableView
298452

The problem is that I can't seem to manage to translate that rectangle into the coordinate system of the detail view (i.e., the map in the background). I've tried using this code: CGRect cellRect = [tableView rectForRowAtIndexPath:indexPath];
CGRect cellRectInWindow = [tableView.window convertRect:cellRect toWindow:self.detailView.view.window];

but that provides an identity transformation, and hence I'm asking for a little help - how can I get that rectangle into the coordinate system of the detail view?



jnoxx
Aug 11, 2011, 02:37 AM
You know in the guidelines, it only allows you to have 1 Popover at a time right?
If you pop a second popover (by HIG) it tells you to dismiss your first one.

RonC
Aug 11, 2011, 04:44 PM
You know in the guidelines, it only allows you to have 1 Popover at a time right?
If you pop a second popover (by HIG) it tells you to dismiss your first one.

Thanks for the reminder.

I've been having a lot of trouble with this (though I did manage to get the coordinate transformation to work EXCEPT when I rotated the device). Turns out the world is a better place now that I've redesigned this part of the interface to just push another view controller to show the content that would have been in the 2nd popover.

This app won't have to go through the approval process, but it doesn't mean I shouldn't follow the HIG.