文件预览

UIDocumentInteractionController

初始化对象

网上有资料说要用这个属性要用retain,我也不知道为啥........


实现的代理方法

源码:

1.引入协议<UIDocumentInteractionControllerDelegate>

2.初始化,签代理

_doc = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];

 _doc.delegate = self;//设置代理

 [self.doc presentPreviewAnimated:YES]; 

presentPreviewAnimated:YES,弹出预览窗口

presentOptionsMenuFromRect:inView:animated;不弹出预览窗口,直接弹出菜单(还有很多方法)

3.实现代理方法

#pragma mark -------------documentDelegate---------

- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller {

    return self;

}

- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller {

    return self.view;

}

- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller {

    return  self.view.frame;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容