UIActivityViewController.completionWithItemsHandler is not called in iOS 10.0 when I select the Print menu and cancel it

I created a simple application that uses UIActivityViewControlleras shown below.

    let text = "Test Text"
    let printData = UISimpleTextPrintFormatter(text: text)
    let vc = UIActivityViewController(activityItems: [text, printData], applicationActivities: nil)
    vc.completionWithItemsHandler = { (type,completed,items,error) in
        print("completed. type=\(type) completed=\(completed) items=\(items) error=\(error)")
    }

    vc.modalPresentationStyle = .popover
    vc.popoverPresentationController?.sourceView = self.openActivityButton
    vc.popoverPresentationController?.sourceRect = self.openActivityButton.bounds
    vc.popoverPresentationController?.permittedArrowDirections = .up
    vc.popoverPresentationController?.delegate = self

    self.present(vc, animated: true) { () in
    }

and I run this application on iOS 10 (Xcode 8.0 beta 6).

  • When I close the activity dialog, it is called completionWithItemsHandler.
  • When I select the "Copy" action, it is called completionWithItemsHandler.
  • When I select the action "Mail" and cancel it, it is called completionWithItemsHandler.
  • But when I select "Print" and cancel it, it completionWithItemsHandleris not called .

This strange behavior happened on iOS 10 but did not happen on iOS9 (the handler was called on iOS9)

IOS 10? , - UIActivityController ?

https://github.com/kunichiko/ios10-activity-bug

+4
1

. , , UIActivityController . , , , . .

+4

Source: https://habr.com/ru/post/1651743/


All Articles