PopOver frame issue in iPhone SDK

江枫思渺然 提交于 2019-12-13 06:59:17

问题


I display a popover in map view as follows:

But when i rotate the device, It shows Like:

as you see it covers the annotation instead of showing just beside the annotation.

My code is as as shown below:

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

Help me to solve this problem.


回答1:


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.



来源:https://stackoverflow.com/questions/14659786/popover-frame-issue-in-iphone-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!