在iOS 8上调用系统共享菜单
我正试图弄清楚如何以编程方式显示系统共享菜单,但我能找到的所有信息都是在iOS 8上调用系统共享菜单,ios,swift,ios8,ios8.3,Ios,Swift,Ios8,Ios8.3,我正试图弄清楚如何以编程方式显示系统共享菜单,但我能找到的所有信息都是 如何以编程方式调用该对话框?您需要创建UIActivityViewController的实例,下面是一个快速示例 let objectsToShare = ["a string"] let activityController = UIActivityViewController( activityItems: objectsToShare, applicationActivities: ni
如何以编程方式调用该对话框?您需要创建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)
您需要创建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)
如何检查是否显示为popover?我在回答中添加了一个带有必需属性的快速示例如何检查是否显示为popover?我在回答中添加了一个带有必需属性的快速示例