I created a simple application which uses UIActivityViewController
as 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 activity dialog, the
completionWithItemsHandler
is called. - When I select "Copy" activity, the
completionWithItemsHandler
is called. - When I select "Mail" activity and cancel it, the
completionWithItemsHandler
is called. - But, when I select "Print" activity and cancel it, the
completionWithItemsHandler
is not called.
This strange behavior occurred on iOS 10 but not occurred on iOS9 (the handler was called on iOS9)
Is this iOS 10's bug? If so, are there any workarounds to detect the UIActivityController
is dismissed?
I pushed this sample app on https://github.com/kunichiko/ios10-activity-bug