本文介绍了确定使用了哪个共享扩展程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于在iOS 8中已经弃用了 completionHandler
on UIActivityViewController
,是否有任何方法来确定哪个共享扩展/活动是由用户使用的?
Since the completionHandler
on UIActivityViewController
was deprecated in iOS 8, is there any way to determine which share extension/activity was used by the user?
推荐答案
您只需要使用新的处理程序 UIActivityViewControllerCompletionWithItemsHandler
:
You just need to use the new handler UIActivityViewControllerCompletionWithItemsHandler
:
typedef void (^UIActivityViewControllerCompletionWithItemsHandler)(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError);
这样调用:
[yourActivityVC setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError){
}];
此外,如果您想知道选择了什么项目,您只需要确保您的活动项目符合 UIActivityItemSource
协议;
Additionally, if you're wondering about knowing what item was selected, you just need to ensure your activity items conform to the UIActivityItemSource
protocol;
这篇关于确定使用了哪个共享扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!