2つのセクションを持つテーブルビューがあり、どちらも2つの異なる配列を呼び出します。マルチビュー配列を持つTableView segue
var data1 = [Data]()
var data2 = [Data]()
let section = ["Section1", "Section2"]
どのようにしてセグの情報を渡すことができますか?
これは私の情報です。「データ」は別ファイルの構造体です。
let destination = segue.destinationViewController as! DetailsViewController
let selectedInfo = data1[indexPath.row]
destination.detailsTitle.text = selectedInfo.dataTitle
destination.detailsImage.image = selectedInfo.dataImage
destination.detailsInfo.text = selectedInfo.dataDetails
destination.detailsGenre.text = selectedInfo.dataGenre
しかし、私は2つの配列を持っていますが、どうすればよいか分かりません。また、この情報は機能しません。渡された情報はゼロで、私のアプリケーションはクラッシュします。どちらの配列にも情報が付加されています。
これは全体セグエです:私のアレイ上
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == cellIdentifier {
let destination = segue.destinationViewController as! DetailsViewController
if let indexPath = self.tableView.indexPathForSelectedRow {
let selectedInfo = data1[indexPath.row]
destination.detailsTitle.text = selectedInfo.dataTitle
destination.detailsImage.image = selectedInfo.dataImage
destination.detailsInfo.text = selectedInfo.dataDetails
destination.detailsGenre.text = selectedInfo.dataGenre
}
}
}
情報はこれです...
let pic1 = UIImage(named: "killlakill")
var animeInfo = Data(title: "Kill la Kill", image: pic1!, details: "The story is set on a high school that the student council president Satsuki Kiryuuin rules by force. Wielding a giant Basami scissors sword, the wandering transfer student Ryuuko Matoi brings about upheaval on the campus. Ryuuko searches for the mysterious figure who caused her father's death, but confronting her are the student council's four divine kings. Fortunately, Ryuuko is aided by a talking sailor uniform who tells her, Wear me. When I am worn by you, this power will become manifest.", genre: "School, Comedy, Action", episodes: "24")
data1.append(animeInfo)
のように...テーブルビューコントローラで
data1はData1 [indexPath.row]で大文字になります。それはタイプミスですか? – Shades
ええ、ここでタイプミス...申し訳ありません...それはxcodeの上にそのように見えません – art3mis
私は何が起こっているのかを完全には知りません。どのようにindexPath.rowを取得していますか?正確なエラーとは何ですか? 2つ目のビューコントローラで実際の変数に値を代入する必要があるようですが、ラベル自体に代入する必要はありません。 – Shades