2017-02-12 4 views
3

UIDocumentInteractionController를 사용하여 파일을 보내고 처리 중입니다.
파일 전송 후 완료 경고를 표시하려고합니다.
그러나 완료 이벤트를 감지 할 수 없어 경고를 표시 할 수 없습니다.
완료 이벤트를 감지하는 방법을 알려주십시오.DidEndSendingToApplication이 호출되지 않았습니다.

import UIKit 

class ViewController: UIViewController, UIDocumentInteractionControllerDelegate { 

// Document controller 
var dic:UIDocumentInteractionController?  
override func viewDidLoad() { 
    super.viewDidLoad() 
} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Dispose of any resources that can be recreated. 
} 


@IBAction func export(_ sender: Any) { 
    // url is sample. 
    let url = URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask, true)[0]).appendingPathComponent("sample.txt") 

    dic = UIDocumentInteractionController(url: self.url) 
    dic?.delegate = self 
    dic?.presentOpenInMenu(from: (self.tabBarController?.tabBar.frame)!, in: self.view, animated: true) 
} 

// MARK: UIDocumentInteractionControllerDelegate methods 
// Open in menu presented/dismissed on document. Use to set up any HI underneath. 
public func documentInteractionControllerWillPresentOpenInMenu(_ controller: UIDocumentInteractionController) { 
    // Called 
    print("WillPresentOpenInMenu") 
} 

public func documentInteractionControllerDidDismissOpenInMenu(_ controller: UIDocumentInteractionController) { 
    // Called 
    print("DidDismissOpenInMenu") 
} 


// Synchronous. May be called when inside preview. Usually followed by app termination. Can use willBegin... to set annotation. 
public func documentInteractionController(_ controller: UIDocumentInteractionController, willBeginSendingToApplication application: String?) { 
    // Not Called 
    print("willBeginSendingToApplication") 
} 


public func documentInteractionController(_ controller: UIDocumentInteractionController, didEndSendingToApplication application: String?) { 
    // Not Called 
    print("didEndSendingToApplication") 

    // I want to display an alert of completion! 
    let alert = UIAlertController(title: "Completed", message: "", preferredStyle: .alert) 
    alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) 
    self.present(alert, animated: true, completion: nil) 
} 
} 

답변

0

는 슬프게도, 해당 응용 프로그램 (노트, 확장, 공중 투하)로 이동의 오버레이로 보여 주었다있는 애플 리케이션을위한, didEndSendingToApplication가 호출되지 않습니다. 유일한 옵션은 documentInteractionControllerDidDismissOpenInMenu에 알림을 표시하는 것입니다.하지만 전송중인 파일과 닫히는 메뉴를 구별 할 수는 없습니다.