0

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

在此处输入图像描述

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

在此处输入图像描述

如您所见,它覆盖了注释,而不是仅显示在注释旁边。

我的代码如下所示:

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];

帮我解决这个问题。

4

1 回答 1

0

You can try to override the following method (declared in UIViewcontroller.h) :

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

You'll probably need to save the state of your viewController (like isPopoverPresented, which annotation etc.) and update the popover's rect accordingly.

于 2013-02-02T10:35:09.493 回答