2015-07-29 7 views
0

Как открыть URL-адрес в Xcode с помощью SpriteKit с помощью Swift при нажатии на узел спрайтов. Я хочу, чтобы он открывался в Safari, а не в приложении. У меня это до сих пор:Как открыть URL-адрес с помощью SpriteKit и Swift

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{ 
} 
+0

Вы можете открыть URL, как это-UIApplication.sharedApplication() OpenUrl (NSURL (строка: "HTTP : //www.apple.com ")) – Shripada

ответ

0

Таким образом, вы можете открыть ссылку в 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 
    } 
} 
+0

Спасибо большое :) – JGrn84

+0

Рад помочь вам .. :) –

Смежные вопросы