在 iOS 上调用系统共享菜单 8
Calling the system share menu on iOS 8
我正在尝试弄清楚如何以编程方式显示系统共享菜单,但我能找到的所有信息都是 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)
我正在尝试弄清楚如何以编程方式显示系统共享菜单,但我能找到的所有信息都是 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)