如何将共享按钮编码到我的SpriteKit场景中?在Main.storyboard和ViewController.swift中,我已经看过关于如何制作它的教程,我正在将它编码在我的MenuScene.swift (Cocoa类)中,并在MenuScene.sks (SpriteKit场景)中显示。我使用Swift 4和最新版本的Xcode (9.4.1),我的应用程序是针对iOS 9和更高版本的。
提前感谢!
发布于 2018-07-08 20:57:37
此代码将显示一个活动视图,并允许您共享您想要的任何内容。
if var top = scene?.view?.window?.rootViewController {
while let presentedViewController = top.presentedViewController {
top = presentedViewController
}
let activityVC = UIActivityViewController(activityItems: ["This is an array of items that will be shared. Including Images, Numbers, and text (like this)"], applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = view
top.present(activityVC, animated: true, completion: nil)
}
当然,需要在touchesBegan
方法或函数中调用它。要共享一些东西,您需要将其放入activityVC
中的数组中。
这不是一个共享按钮,这只是用于与另一个应用程序共享一些东西的代码。您需要将它放入一个函数或在touchesBegan
中,并在您想要共享的时候单独调用它。
https://stackoverflow.com/questions/51197034
复制相似问题