1

在我的 iOS 应用程序中,我有一个称为 Map View 的地图视图mappa
我只是添加了一个 UIActivityViewController,当从注释视图中按下标注时,它会出现。
我使用此代码来显示它:

- (void)mapView:(MKMapView *)mapView
 annotationView:(MKAnnotationView *)view
 calloutAccessoryControlTapped:(UIControl *)control {

    [mappa deselectAnnotation:view.annotation animated:YES];

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0) {

        UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[self, [NSURL URLWithString:@"http://www.AppStore.com/iToretto"]]
                                                                                             applicationActivities:nil];

        activityViewController.excludedActivityTypes = @[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard ];

        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {

            UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
            self.annotationPopoverController = pop;

            //show the popover next to the annotation view (pin)
            [pop presentPopoverFromRect:view.bounds
                                 inView:view
               permittedArrowDirections:UIPopoverArrowDirectionAny
                               animated:YES];
            self.annotationPopoverController.delegate = self; 
        }
    }
}

我的问题是,当我旋转这个弹出框时,我有一个框架问题(像这样)。我知道解决方案是覆盖:

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

但是当我尝试以这种方式在横向模式下显示弹出框时,我遇到了多个错误:

if (UIInterfaceOrientationLandscapeLeft && [self.annotationPopoverController isPopoverVisible]) {
    [self.annotationPopoverController presentPopoverFromRect:view.bounds
                                                      inView:view
                                    permittedArrowDirections:UIPopoverArrowDirectionAny 
                                                    animated:YES];
}

因为“view.bounds”和“view”是本地声明MKAnnotation

那么,我该如何解决呢?!有没有人有办法解决吗?!提前致谢。

4

0 回答 0