使用AirDrop时,UIActivityViewController完成处理程序已完成 [英] UIActivityViewController completion handler is !completed when using AirDrop
问题描述
我正在使用 UIActivityViewController
来分享一些文本和网址,这些文字和网址在发送一些文字和网址时效果很好。
I am using UIActivityViewController
to share some text and url which works great when sending some text and a url.
我目前需要使用完成处理程序来执行其他操作,具体取决于用户是否取消了 UIActivityViewController
或实际发送了什么。
I currently need to use the completion handler to perform additional actions depending whether the user cancelled the UIActivityViewController
or actually sent something.
在iOS 8中不推荐使用iOS 7的完成处理程序( activityViewController.completionHandler
,现在 activityViewController setCompletionWithItemsHandler
)返回 BOOL已完成
值,当使用 email $ c发送时,该值正确返回
true
$ c> sms
Facebook
Twitter
然而当发送时 Airdrop
用户必须按取消
才能在发送后关闭 UIActivityViewController
因此我总是从完成处理程序中收到 false
。
The completion handler (activityViewController.completionHandler
for iOS 7 is deprecated in iOS 8 which is now activityViewController setCompletionWithItemsHandler
) returns a BOOL completed
value which correctly returns true
when sending with email
sms
Facebook
Twitter
however when sending via Airdrop
the user must press Cancel
to dismiss the UIActivityViewController
once sent and thus I always receive a false
from the completion handler.
有谁知道是否有知道用户在 UIActivityViewController
被解雇时使用 Airdrop
发送的方式?
Does anyone know if there's a way of knowing that the user has sent using Airdrop
when the UIActivityViewController
is dismissed?
谢谢
推荐答案
我发现了一些你感兴趣的东西,但不幸的是我无法测试它因为AirDrop不想在我的iDevices之间运行。很抱歉。
I've found something of interest for you but unfortunately I couldn't test it as AirDrop didn't want to function between my iDevices. Sorry about that.
无论如何,您可以尝试 setCompletionWithItemsHandler
检查 activityType
:
Anyway, you could try setCompletionWithItemsHandler
checking for activityType
:
[activityViewController setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
NSLog(@"completed: %@, \n%d, \n%@, \n%@,", activityType, completed, returnedItems, activityError);
}];
如果 activityType
的类型为 com.apple.airdrop.etc
(只是一个猜测)然后用户点击了图标。希望它可以提供帮助。
If activityType
is of type com.apple.airdrop.etc
(just a guess) then the user has tapped on the icon. Hope it can help.
这篇关于使用AirDrop时,UIActivityViewController完成处理程序已完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!