iPhone SDK中的PopOver框架问题

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

在这里输入图像说明

但是当我旋转的设备,它显示像:

在这里输入图像说明

正如您所看到的那样,它将覆盖注释而不是在注释旁边显示。

我的代码如下所示:

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

帮我解决这个问题。

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

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

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