多くの方法を試しましたが、まだ別のViewController
に行くことはできません。これは私のストーリーボードです。 ViewControllerへのTableViewCell - Swift
これは私のコードです。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? HistoryMainTableViewCell {
listItems.sort() { $0.seq > $1.seq }
let history = listItems[indexPath.row]
cell.setValue(history: history)
return cell
} else {
return HistoryMainTableViewCell()
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "vcProductHistory" {
if let productHistoryPage = segue.destination as? HistoryProductViewController {
if let IndexPath = tableViewHistory.indexPathForSelectedRow {
let historyArray = listItems[IndexPath.row]
productHistoryPage.history = historyArray
}
}
}
}
Segueを 'HistoryMainTableViewCell'から' HistoryProductViewController'に追加しましたか? – lee5783
VCがセグを開始することを知らせるためにイベントが発生する場所でperformSegue関数を追加していますか? – JustinM
@ lee5783すでに追加しました –