我尝试使用以下代码点击单元格,将数据传输到WebView
:
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath:
IndexPath) {
let storyboard = UIStoryboard(name: "App", bundle: nil)
let popup = storyboard.instantiateViewController(withIdentifier: "taskWebVieww")
as! taskWebView
popup.taskVar = ("https://example.com/m_task?id="+self.tskid[indexPath.row]
+"&uid="+UserDefaults.standard.string(forKey: "userID")!)
self.present(popup, animated: true, completion: nil)
}
所以它确实没问题,但我只能在下次点击时获得正确的数据。 首先,它是第二个,它打开了第一个值,所以
WebView代码:
var taskVar: String = "undefined"
override func viewDidLoad()
{
webView.loadRequest(URLRequest(url: URL(string:taskVar)!))
super.viewDidLoad()
}
答案 0 :(得分:0)
使用 didSelectRowAt 代替 didDeselectRowAt