您当前的位置: 首页 >  ui

培根芝士

暂无认证

  • 0浏览

    0关注

    446博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

UIDocumentInteractionController对文件预览或分享

培根芝士 发布时间:2021-11-19 18:13:07 ,浏览量:0

UIDocumentInteractionController本地查看文件
  • 实例化一个UIDocumentInteractionController对象并遵守其delegate
@interface FileReviewController () 

@property (nonatomic, strong) UIDocumentInteractionController *DIController;

@end
NSURL *urlPath = [[NSBundle mainBundle] URLForResource:@"Jobs" withExtension:@"pdf" subdirectory:@"PDF.bundle"];
self.DIController = [UIDocumentInteractionController interactionControllerWithURL:urlPath];
self.DIController.delegate = self;
  • 实现delegate
#pragma mark - UIDocumentInteractionControllerDelegate
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller {
    return self;
}

- (UIView*)documentInteractionControllerViewForPreview:(UIDocumentInteractionController*)controller {
    return self.view;
}

- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController*)controller {
    return self.view.frame;
}
  • 读取本地文件
[self.DIController presentPreviewAnimated:YES];
UIDocumentInteractionController第三方分享
[self.DIController presentOptionsMenuFromRect:self.view.bounds inView:self.view animated:YES];

显示菜单的方法:

- presentOptionsMenuFromRect:inView:animated: - presentOptionsMenuFromBarButtonItem:animated: - presentOpenInMenuFromRect:inView:animated: - presentOpenInMenuFromBarButtonItem:animated:

关注
打赏
1660824269
查看更多评论
立即登录/注册

微信扫码登录

0.0366s