如果您在邮箱中获得pdf文件,请长按pdf文件,然后您将获得包含已安装的pdf阅读器应用程序列表的弹出框。那么如何在那里添加我们的应用程序来打开pdf文件?
答案 0 :(得分:0)
使用UIDocumentInteractionController
- (void)onOpenWith:(UIButton *)theButton path:(NSString *)path
{
NSURL *URL = [NSURL fileURLWithPath:path];
if (URL) {
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
self.documentInteractionController.delegate = self;
[self.documentInteractionController presentOptionsMenuFromRect:CGRectZero
inView:theButton
animated:YES];
}
}
#pragma mark - UIDocumentInteractionControllerDelegate
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
return self.view;
}
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
return self.view.frame;
}