1

私の iOS アプリには、私が呼び出したマップ ビューがあります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