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).
completionWithItemsHandler
is called.completionWithItemsHandler
is called.completionWithItemsHandler
is called.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
I had a similar problem. In my case, I noticed that the completion handler was not called because the UIActivityController was already dismissed and deallocated. What I did was just add a property to hold a strong reference and set it to nil later. Then the completion handler was called properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With