Created
March 26, 2012 11:00
-
-
Save steipete/2204444 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Do I miss something obvious or is this the best way to detect if UIDocumentInteractionController is still open or not? | |
// (BOOL _isShowingOpenInMenu is in the class) | |
- (void)openInAction:(id)sender { | |
// do we need to dismiss a popover? | |
if ([self checkAndDismissPopoverForViewControllerClass:[UIDocumentInteractionController class] animated:YES]) { | |
return; | |
} | |
if (self.document.fileUrl) { | |
_isShowingOpenInMenu = NO; | |
documentInteractionController_ = [UIDocumentInteractionController interactionControllerWithURL:self.document.fileUrl]; | |
documentInteractionController_.delegate = self; | |
if (PSIsIpad()) { | |
[documentInteractionController_ presentOptionsMenuFromBarButtonItem:sender animated:YES]; | |
}else { | |
[documentInteractionController_ presentPreviewAnimated:YES]; | |
} | |
} | |
} | |
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller { | |
documentInteractionController_.delegate = nil; | |
documentInteractionController_ = nil; | |
_isShowingOpenInMenu = NO; | |
} | |
- (void)documentInteractionControllerWillPresentOpenInMenu:(UIDocumentInteractionController *)controller { | |
_isShowingOpenInMenu = YES; | |
} | |
- (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller { | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
if (!_isShowingOpenInMenu) { | |
documentInteractionController_.delegate = nil; | |
documentInteractionController_ = nil; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment