iPhone SDK中的PopOver框架问题 [英] PopOver frame issue in iPhone SDK
本文介绍了iPhone SDK中的PopOver框架问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在地图视图中显示一个弹出窗口,如下所示:
I display a popover in map view as follows:
但是当我旋转设备时,它显示为:
But when i rotate the device, It shows Like:
< img src =https://i.stack.imgur.com/zbSCz.pngalt =在此处输入图片说明>
如您所见它涵盖了注释,而不是仅显示在注释旁边。
我的代码如下所示:
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 中声明):
You can try to override the following method (declared in UIViewcontroller.h) :
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
您可能需要保存viewController的状态(如isPopoverPresented,哪个注释等)并相应地更新popover的矩形。
You'll probably need to save the state of your viewController (like isPopoverPresented, which annotation etc.) and update the popover's rect accordingly.
这篇关于iPhone SDK中的PopOver框架问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文