Coordinate transformation between Popover and background view

Discussion in 'iOS Programming' started by RonC, Aug 10, 2011.

  1. RonC macrumors regular

    Oct 18, 2007
    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)
    Screen shot 2011-08-10 at 3.10.30 PM.png

    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
    Screen shot 2011-08-10 at 3.11.51 PM.png

    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?
  2. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    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.
  3. RonC thread starter macrumors regular

    Oct 18, 2007
    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.

Share This Page