我有两个部分的表视图,都调用两个不同的数组。TableView继承multipe数组
var data1 = [Data]()
var data2 = [Data]()
let section = ["Section1", "Section2"]
如何通过segue传递两者的信息?
这是我为segue提供的信息,“Data”是一个单独的文件上的结构。我有两个数组,但我不知道如何去做。此外,这些信息不起作用。它说传递的信息是零,我的应用程序崩溃。两个数组都有信息附加到它。
这是整个SEGUE:
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?什么是确切的错误和地点?看来你需要将值赋给第二个视图控制器中的实际变量,而不是分配给标签本身。 – Shades