来自 UIActivityType 的 UIActivity

UIActivity from UIActivityType

有没有办法从现有的 UIActivityType 获取 UIActivity?

所以我可以像这样构建 UIActivityViewController:

let activityViewController = UIActivityViewController(activityItems: [],
   applicationActivities: [MyActivity(),"TypeUIActivity"])

present(activityViewController, animated: true, completion: {})

阅读 Apple documentation 关于这个的内容,我读到:

Subclassing Notes

This class must be subclassed before it can be used. The job of an activity object is to act on the data provided to it and to provide some meta information that iOS can display to the user. For more complex services, an activity object can also display a custom user interface and use it to gather additional information from the user. “

这意味着您需要创建 UIActivity 的自定义实现并覆盖其功能以创建您希望使用的方法。就像创建 CollectionViewCell 的自定义实现一样。