【发布时间】:2012-05-12 12:03:54
【问题描述】:
我查看了几个选项,例如:
*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?
我正在尝试在 mapview 中显示地图注释的弹出框。目前我正在使用一种解决方法。我在我的故事板视图控制器中创建了一个视图,并将我的弹出框锚定到该视图。我将视图移动到正确的位置,然后使用以下方法加载弹出框:
(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];
我的直觉是不需要这种解决方法。有没有更简单、更优雅的方法来做到这一点?
谢谢, 马赫什
【问题讨论】:
-
看看this answer是否有帮助。
-
谢谢安娜。我正在使用 segues 启动弹出框 - 因此我无法正确定位弹出框。
如果您使用 segue,我相信我使用的解决方法适用于定位弹出框。话虽如此,我现在正在使用您的答案建议的方法。self.detailsPopover = [[self storyboard] instantiateViewControllerWithIdentifier:@"identifierName"];干杯,马赫什