diff --git a/AttachmentHandler.swift b/AttachmentHandler.swift index 170a1e7..34a4ee3 100644 --- a/AttachmentHandler.swift +++ b/AttachmentHandler.swift @@ -81,11 +81,14 @@ class AttachmentHandler: NSObject{ })) actionSheet.addAction(UIAlertAction(title: Constants.file, style: .default, handler: { (action) -> Void in - self.documentPicker() + self.documentPicker(vc: vc) })) actionSheet.addAction(UIAlertAction(title: Constants.cancelBtnTitle, style: .cancel, handler: nil)) - + actionSheet.popoverPresentationController?.sourceView = vc.view + actionSheet.popoverPresentationController?.permittedArrowDirections = [] + actionSheet.popoverPresentationController?.sourceRect = CGRect(x: vc.view.bounds.midX, y: vc.view.bounds.midY, width: 0, height: 0) + vc.present(actionSheet, animated: true, completion: nil) } @@ -174,8 +177,11 @@ class AttachmentHandler: NSObject{ } //MARK: - FILE PICKER - func documentPicker(){ + func documentPicker(vc: UIViewController){ let importMenu = UIDocumentMenuViewController(documentTypes: [String(kUTTypePDF)], in: .import) + importMenu.popoverPresentationController?.sourceView = vc.view + importMenu.popoverPresentationController?.permittedArrowDirections = [] + importMenu.popoverPresentationController?.sourceRect = CGRect(x: vc.view.bounds.midX, y: vc.view.bounds.midY, width: 0, height: 0) importMenu.delegate = self importMenu.modalPresentationStyle = .formSheet currentVC?.present(importMenu, animated: true, completion: nil)