Вопрос

I've a problem with UIDocumentInteractionController. I'm able, through presentOptionsMenuFromBarButtonItem, to display the popover correctly.

When the user touch the barbuttonitem I fire the following method:

- (IBAction)share:(id)sender {

   if (docIntController) {
      [docIntController dismissMenuAnimated:NO];
      docIntController = nil;
   }
   NSString *fileURL = [(Documents *)(self.detailItem) url];
   NSArray *subStrings = [fileURL componentsSeparatedByString:@"/"];
   NSString *filePath = [[self documentsDirectory] stringByAppendingPathComponent:[subStrings lastObject]];

   docIntController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
   docIntController.delegate = self;
   docIntController.UTI = @"com.adobe.pdf";

   [docIntController presentOptionsMenuFromBarButtonItem:sender animated:YES];

}

Anyway, when the user touches the print button, and then again the barbutton, the print option menu will not disappear, as you can see in the following image:

enter image description here

Moreover, if the user touches the print option again, the option popover will disappear (but not the old print option) and another print option popover will be created.

Indeed if the user touches outside of the popover to dismiss it, only the first one will be dismissed and the old one is empty as shown below:

enter image description here

Это было полезно?

Решение

I solved this by calling the dismissAnimated method on the UIPrintInteractionController

- (IBAction)share:(id)sender {
    [[UIPrintInteractionController sharedPrintController] dismissAnimated:NO];

    // remainder of share method code
}

You may want to break the dismissal code (both the UIPrintInteractionController and the DocumentInteractionController) into a separate method and simply call it in the share method. I ran into an issue where the print menu didn't dismiss in portrait mode on the iPad so I added a call to dismiss it in viewWillDisappear.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top