16

Tôi có một VC "A" hiện tại VC "B" một cách bình thường. B trình bày một giao thức UIDocumentMenuViewController Các UIDocumentMenuDelegate được thực hiện trong B.UIDocumentMenuViewController loại bỏ trình điều khiển xem trình bày

Ngay sau khi documentMenuWasCancelled(_ documentMenu:) hoặc documentMenu(_:didPickDocumentPicker:) được gọi là dismiss(animated:completion:) của B được gọi và tôi không có đầu mối tại sao.

Dưới đây là mã của tôi

func presentDocumentPicker() { 
    let documentTypes = [ 
     kUTTypeCompositeContent as String, 
     kUTTypePDF as String, 
     "com.microsoft.word.doc", 
     "vnd.openxmlformats-officedocument.wordprocessingml.document" 
    ] 
    let documentMenuViewController = UIDocumentMenuViewController(documentTypes: documentTypes, in: .import) 
    documentMenuViewController.delegate = self 
    present(documentMenuViewController, animated: true, completion: nil) 
} 

// MARK: - Document Menu View Controller Delegate 

func documentMenu(_ documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) { 
    print("did pick") 
} 

func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) { 
    print("was cancelled") 
} 

Như bạn có thể thấy tôi không phải làm gì trong hàm đại biểu thực hiện. Và B vẫn bị bác bỏ. Tôi không hiểu.

+0

Bạn có thể gửi nhiều dự án đến hoặc ít nhất toàn bộ ViewControllers bạn có ở đó không? –

+0

Thực ra ngay bây giờ tôi không thể tái tạo nó: D – lukwuerz

+0

có thể có vấn đề về cách bạn trình bày cả hai bộ điều khiển .. –

Trả lời

0

Điều này là do phương pháp documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) được gọi khi bạn nhấp vào một hành động hoặc khi bạn hủy UIDocumentMenuViewController.

Tôi đã đăng một giải pháp ở đây: https://stackoverflow.com/a/45505488/6381503

Hy vọng điều đó sẽ hữu ích.

Các vấn đề liên quan