我正在尝试弄清楚如何以编程方式显示系统共享菜单,但我能找到的所有信息都是 how to register an app to said menu .
如何以编程方式调用对话框?
最佳答案
你需要创建一个 UIActivityViewController 的实例,这里是一个简单的例子
let objectsToShare = ["a string"]
let activityController = UIActivityViewController(
activityItems: objectsToShare,
applicationActivities: nil)
// if your app can run on an iPad, this menu
// will present as a pop over controller
// and as such, needs to be configured
// consider the bar button item property
// if needed
// should be the rect that the pop over should anchor to
activityController.popoverPresentationController?.sourceRect = view.frame
activityController.popoverPresentationController?.sourceView = view
activityController.popoverPresentationController?.permittedArrowDirections = .any
// present the controller
present(activityController, animated: true, completion: nil)
关于ios - 在 iOS 8 上调用系统共享菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31880782/