如何更改UIPopover的锚点? PresentFromRect对我无法正常工作。

问题描述:

我也考虑过多种选项,如:如何更改UIPopover的锚点? PresentFromRect对我无法正常工作。

* http://blog.waynehartman.com/archive/2012/01/07/uistoryboard-on-ios-5-the-good-the-bad-and-the.aspx * UIPopoverController Anchor Position * Can I change the UIPopover animation anchor point?

我试图显示在图形页面的地图注释的酥料饼。目前我正在使用一种解决方法。我在故事板视图控制器中创建了一个视图,并将我的popover锚定到该视图。余移动视图到正确的位置,然后使用加载酥料饼:

(a)中找到的注释的位置

CGPoint annotationPoint = [_mapView convertCoordinate:self.selectedAnnotationView.annotation.coordinate toPointToView:_mapView]; 
float boxDY= annotationPoint.y; 
float boxDX= annotationPoint.x; 
CGRect box = CGRectMake(boxDX,boxDY,1,1); 

(b)中移动,我在故事板创建的视图(anchorView)于注释位置

anchorView.frame = box; 

(c)示出酥料饼

[annotationPopoverController presentPopoverFromRect:box inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO]; 

中号我的直觉是,这种解决方法是不需要的。有没有更简单更优雅的方式来做到这一点?

感谢, 马赫什

+0

看看[这个答案](http://stackoverflow.com/questions/5582564/how-do-i-display-a-uipopoverview-as-a-annotation-to-the-map -view-ipad/5583505#5583505)有帮助。 – Anna

+0

谢谢安娜。 我用塞格斯推出酥料饼 - 所以我不能正确定位酥料饼。
我相信我使用的解决方法适合定位弹出窗口,如果您使用的是segues。 说了这么多,我现在使用你的答案建议的方法。 'self.detailsPopover = [[self storyboard] instantiateViewControllerWithIdentifier:@“identifierName”]; ' 干杯, 马赫什 – Mahesh

感谢安娜。对于重复发布的道歉 - 对Stackoverflow标记有点麻烦。

我用塞格斯推出酥料饼 - 所以我不能正确定位酥料饼。

我相信,我所使用的解决办法是适当的,如果你正在使用塞格斯定位酥料饼。

说了这么多,我现在使用你的答案建议的方法。

我启动使用

self.detailsPopover = [[self storyboard] instantiateViewControllerWithIdentifier:@"identifierName"]; 

//... config code for the popover 

UIPopoverController *pc = [[UIPopoverController alloc] initWithContentViewController:detailsPopover]; 

//... store popover view controller in an ivar 

[self.annotationPopoverController presentPopoverFromRect:selectedAnnotationView.bounds inView:selectedAnnotationView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

我创建使用表和动态锚点类似的答案酥料饼。在我的解决方案中,您可以使用segues保留故事板的流程。你必须稍微修改答案,但基本上是一样的。

Is it possible to perform a Popover Segue manually (from dynamic UITableView cell)?