我有兩個部分的表視圖,都調用兩個不同的數組。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