无法打开"打开"从UIDocumentInteractionController(iPad iOS 8+)调用的菜单

时间:2014-11-24 21:41:57

标签: ios8 uidocumentinteraction ios8.1

我正在开发适用于iPhone和iPad的iOS应用,我有一个问题。

这是附加到UIBarButton的代码。

- (IBAction)saveFile:(id)sender {

  NSURL *theRessourcesURL = [[self.webView request] URL];
  NSString *filename = [theRessourcesURL lastPathComponent];
  NSString *docPath = [self documentsDirectoryPath];
  NSString *pathToDownloadTo = [NSString stringWithFormat:@"%@/%@", docPath, filename];

  NSData *tmp = [NSData dataWithContentsOfURL:theRessourcesURL];
  // Save the loaded data if loaded successfully
  if (tmp != nil) {
    NSError *error = nil;
    // Write the contents of our tmp object into a file
    [tmp writeToFile:pathToDownloadTo options:NSDataWritingAtomic error:&error];
    if (error != nil) {
      // Display an UIAlertView that shows the users we don't saved the file
      UIAlertView *filenameAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Report don't saved",nil) message:[self titleAlert:filename] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
      [filenameAlert show];
    }
  } else {
    // Display an UIAlertView that shows the users we don't saved the file
    UIAlertView *filenameAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Report don't saved",nil) message:[self titleAlert:filename] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
   [filenameAlert show];
  }

 // "Open it and options.." menu
 self.menuController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:pathToDownloadTo]];
 self.menuController.delegate = self;
 [self.menuController presentOpenInMenuFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];
 [self.menuController presentOptionsMenuFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];
}

这样构建没有问题,并且在iOS 7下运行,这段代码运行正常。

问题是,在iOS 8+中,当在iPad上运行时,它会显示此警告:

LaunchServices: invalidationHandler called
Warning: Attempt to present <_UIDocumentActivityViewController: 0x1601004c0> on <UINavigationController: 0x15cd9a650> while a presentation is in progress!

在界面上&#34;打开...&#34;菜单快速显示和隐藏,用户无法在菜单上选择任何选项。在iPhone上也出现警告,但是&#34;打开...&#34;菜单工作正常。

0 个答案:

没有答案