我环顾四周,没有人在 Swift 中找到这个答案,所以就在这里。我收到一条错误消息,指出游戏场景没有名为 presentViewController
的成员。
var alertController = UIAlertController(title: "Nothing Selected",
message: "You have not selected a picture.",
preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Dang!",
style: UIAlertActionStyle.Cancel,
handler: nil))
self.presentViewController(alertController,
animated: true,
completion: nil)
最佳答案
在你的最后一行代码中,而不是
self.presentViewController(alertController, animated: true, completion: nil)
尝试
self.view?.window?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)
这对我有用。 :)
关于swift - 如何在 Skscene SWIFT 中呈现 UIAlert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32790919/