2017-05-04 65 views
0

我在嘗試製作一個UIAlertaction,它可以讓我的遊戲用戶訪問我的網站,以查看高分和其他高分。無法找到教程來向我展示如何編碼URL。因此,可以使用該操作來取代我的用戶訪問網站,而不是採取警報措施來解除警報。我使用了一個教程來得到這麼遠。我是xcode8的新手,我正在學習。對不起,如果這是一個愚蠢的問題。我正竭盡全力。感謝您提前提供的所有幫助。任何幫助都會很棒。源代碼將是巨大的。我也使用的Xcode 8.感謝這麼多UIAlert Action xcode 8

func handleReceivedDataWithNotification(_ notification: Notification) { 
    let gameset = notification.gameset! 
    print(gameset) 
} 

func browserViewControllerDidFinish(_ browserViewController: MCBrowserViewController) { 
    appDelegate.MPCHandler.browser.dismiss(animated: true, completion: nil) 
} 
+0

想要在safari中打開外部網站嗎?或者一個webview? – dirtydanee

+0

@dirtydanee是的,safari中的外部網站。謝謝你回覆 – jake

+0

發表我的回答。 – dirtydanee

回答

1

所有你需要做的,是宣佈你想打開的URL,並喂壞男孩合適的API。

func createAlert (title: String, message:String) 
{ 
    let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert) 
    alert.addAction(UIAlertAction(title: output.text, style: UIAlertActionStyle.default, handler: { (action) in 
     // Declare a URL what you would like to open 
     let url = URL(string: "http://test.io")! 
     // Open website in Safari Mobile 
     UIApplication.shared.open(url, options: [:], completionHandler: nil) 
    })) 
    self.present(alert,animated: true, completion:nil) 
}