【问题标题】:How i can open pdf into iphone for selected pdf viewer?如何为选定的 pdf 查看器打开 pdf 到 iphone?
【发布时间】:2014-06-26 11:57:04
【问题描述】:

如果您在邮箱中获得 pdf 文件,长按 pdf 文件,那么您将获得弹出框,其中包含您已安装的 pdf 阅读器应用程序的列表。那么如何添加我们的应用来打开pdf文件呢?

【问题讨论】:

标签: ios iphone ios7


【解决方案1】:

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;
}

【讨论】:

    猜你喜欢
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    • 2020-09-22
    • 2022-06-11
    • 2012-07-17
    • 2019-01-26
    • 2019-04-03
    • 1970-01-01
    相关资源
    最近更新 更多