我正在尝试将数据传输到
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()
}