Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS 8上调用系统共享菜单_Ios_Swift_Ios8_Ios8.3 - Fatal编程技术网

在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?我在回答中添加了一个带有必需属性的快速示例