我试图通过单击具有以下代码的单元格将数据传输到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)
}
因此,这确实可以,但是我只能在下次点击时获得正确的数据。
首先是nill,其次是打开第一个值,等等
WebView代码:
var taskVar: String = "undefined"
override func viewDidLoad()
{
webView.loadRequest(URLRequest(url: URL(string:taskVar)!))
super.viewDidLoad()
}
最佳答案
使用didSelectRowAt代替didDeselectRowAt
关于ios - 将数据传输到WebView,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48168312/