开发者

Getting co-ordinates of UIPopoverController

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).

开发者_JAVA百科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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜