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