0
我一直在嘗試打開一個URL,當我點擊一個單元格在我的tableview programatticaly,而無需使webview控制器和seques混亂。任何幫助我如何才能做到這一點。以下是我試過的代碼tableviewcell打開網址點擊迅速
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 0 {
NSURL(string: "App Store Link")!
}
else if indexPath.row == 1 {
NSURL(string: "Send Us Feedback - Contact On Website")!
} else if indexPath.row == 2 {
NSURL(string: "https://www.instagram.com/prs_app/")!
} else if indexPath.row == 3 {
NSURL(string: "Snapchat")!
}
}
我很感激幫助。由於
我試過了,它的工作原理,但在更改每個單元格的網址的情況下,它只有goe s到單元格的第一個鏈接(0 - apple.com)。有沒有辦法讓每個細胞進入不同的環節? –
「如果indexPath.row == 0 { UIApplication.sharedApplication()的OpenURL(NSURL(字符串: 」http://www.apple.com「))。 } 否則,如果indexPath.row == 1 UIApplication.sharedApplication()。openURL(NSURL(string:「http://www.apple.com」)!) } else if indexPath.row == 2 {UIApplication.sharedApplication()。openURL(NSURL( string:「http://www.instagram.com/prs_app」)!) } else if indexPath.row == 3 UIApplication.sharedApplication()。openURL(NSURL(string:「http://www.snapchat .com「)!) }' –
好吧,你確定你點擊正確的單元格嗎?或者你確定你不會混淆行和部分?因爲如果你的'UITableView'有4行,你的代碼應該可以工作(有更清晰的方法來寫它) –