在我的应用程序中,我添加了共享扩展程序,它工作正常,但是当我通过邀请应用程序时遇到一个问题,UIActivityViewController
我显示了我的应用程序扩展程序。如何隐藏我自己的应用程序的应用程序扩展?
问问题
1354 次
2 回答
0
您可以通过在排除的活动类型列表中添加您的扩展活动类型来做到这一点:
let activityViewController = UIActivityViewController(activityItems: <your items>, applicationActivities: <your supported application activities>)
let extensionActivityType = UIActivityType(<your extension activity type id>)
activityViewController.excludedActivityTypes = [extensionActivityType]
于 2018-01-16T15:27:57.837 回答
0
抱歉迟到了,但希望这个答案能帮助你。
首先在您的代码中定义以下行
class ActionExtensionBlockerItem: NSObject, UIActivityItemSource {
func activityViewController(_ activityViewController: UIActivityViewController, dataTypeIdentifierForActivityType activityType: UIActivityType?) -> String {
return "com.your.unique.uti";
}
func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivityType) -> Any? {
// Returning an NSObject here is safest, because otherwise it is possible for the activity item to actually be shared!
return NSObject()
}
func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivityType?) -> String {
return ""
}
func activityViewController(_ activityViewController: UIActivityViewController, thumbnailImageForActivityType activityType: UIActivityType?, suggestedSize size: CGSize) -> UIImage? {
return nil
}
func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
return ""
}
}
这里com.your.unique.uti是您的应用程序组标识符 ,然后在呈现 activityViewController 时使用下面的代码
let activityViewController = UIActivityViewController(activityItems: [/* Other Items To Share, */ ActionExtensionBlockerItem()], applicationActivities: nil)
于 2019-07-11T10:42:45.077 回答