ios - 在 iOS 8 上调用系统共享菜单

标签 ios swift ios8 ios8.3

我正在尝试弄清楚如何以编程方式显示系统共享菜单,但我能找到的所有信息都是 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/

相关文章:

ios - UITableViewCell 无意中在不需要的行上放置了复选标记

javascript - 如何从 block 函数中获取数据?

ios - 更新到 iOS 8 使我的 SpriteKit 游戏变得 super 慢

ios - 如何使用 CoreData 从选定的 Collection View 单元格中获取标签文本?

ios - 重用后如何使自定义 UITableViewCell 顶部单元格唯一绘制?

ios - 将静态库添加到 Xcode 项目时出现重复符号

ios - 尝试在我的应用程序中使用 TPKeyboardAvoding Scroll

ios - 使用 AVMutableComposition 导出镜像视频会导致调整大小问题

swift - 自定义 NSError 怪异行为 Swift

ios - 对象必须是 PHAsset 类型