Reputation: 750
How do you open a URL in Xcode using SpriteKit with Swift when a sprite node is pressed. I want it to open in Safari rather than inside the app. I have this so far:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
for touch in (touches as! Set<UITouch>) {
let location = touch.locationInNode(self)
if self.nodeAtPoint(location) == self.WebButton{
}
Upvotes: 1
Views: 822
Reputation: 71854
This way you can open link in Safari:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
for touch in (touches as! Set<UITouch>) {
let location = touch.locationInNode(self)
if self.nodeAtPoint(location) == self.WebButton{
UIApplication.sharedApplication().openURL(NSURL(string: "http://www.stackoverflow.com")) //you can add your link here
}
}
Upvotes: 2