views:

23

answers:

1

I want to use the UIPopoverController for a floating toolbar, as it does well at displaying in the best possible location. However it looks really ugly, with that thick black bar around it (and also the logic of using it for a toolbar is a bit hairy).

So I am going to have a custom view for the toolbar. But I don't want to reinvent all the complex position calculations necessary for displaying from a rect that may be affine-transformed, and/or half off screen.

So I thought that if I had a popover that was invisible, I could use its coordinates for displaying my toolbar.

I can do what I want by using coordinates from a UIMenuController (menuFrame), but the UIMenuController does not display in the best position when the rect is affine-transformed.

So is there any way of determining the co-ordinates of a popover?

A: 

Always the case - hunt for days, and find the answer as soon as I ask it :).

Convert the frame of the viewController's view used by UIPopoverController to the main view's co-ordinates.

CGPoint pt = [popoverViewController.view convertPoint:popoverViewController.view.frame.origin toView:mainView];

Then set the toolbar's view.frame.origin to pt.

Then dismiss the popover so that it does not show.

Caroline