你好
,我搜索了这个,但没有得到任何有用的东西。
我需要获得UIDocumentInteractionController
的"Done
"按钮单击操作。谁能指导我?我正在为iPhone和iPad制作一个应用程序。
更新:- 我还需要隐藏右上角的"Share
"按钮。
提前谢谢。
您可以通过 UIDocumentInteractionController 的委托确定用户是否选择了"完成"。只是:
@interface MyClass : NSObject <UIDocumentInteractionControllerDelegate>
...
@end
...
UIDocumentInteractionController* controller = ...;
controller.delegate = self;
...
- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
NSLog(@"User has dismissed preview");
}
至于删除"共享",这并不容易,Apple建议您在所有情况下都应该拥有它。这是有道理的,如果您正在预览PDF,用户可能非常希望在专用的PDF阅读器中查看它,或通过电子邮件发送它。如果出于业务/安全原因不希望共享功能,则需要尝试自己呈现文档。如何完成这取决于文档,
对于 Swift 3.2
您可以添加此委托方法,以便在 UIDocumentInteractionController 中单击完成按钮时执行操作。
func documentInteractionControllerDidEndPreview(_ controller: UIDocumentInteractionController) {
print("Done Button called here")
}