iPhone SDK中的PopOver框架问题

时间:2013-02-02 07:43:37

标签: ios xcode ipad mkmapview uipopovercontroller

我在地图视图中显示一个弹出窗口,如下所示:

enter image description here

但是当我旋转设备时,它显示为:

enter image description here

,因为您看到它覆盖了注释,而不是显示在注释旁边。

我的代码如下所示:

CGPoint annotationPoint = [mapView convertCoordinate:aView.annotation.coordinate toPointToView:mapView];
        float boxDY=annotationPoint.y;
        float boxDX=annotationPoint.x;
        CGRect box = CGRectMake(boxDX,boxDY,5,5);


        UILabel *displayLabel = [[UILabel alloc] initWithFrame:box];


         [popView presentPopoverFromRect:displayLabel.frame inView:mapView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


        [displayLabel release];

帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

您可以尝试覆盖以下方法(在 UIViewcontroller.h 中声明):

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;

您可能需要保存viewController的状态(如isPopoverPresented,注释等)并相应地更新popover的rect。

相关问题