두 개의 섹션이있는 테이블보기가 있는데 두 가지 모두 서로 다른 배열을 호출합니다.멀티 뷰 배열이있는 TableView segue
var data1 = [Data]()
var data2 = [Data]()
let section = ["Section1", "Section2"]
어떻게 둘 모두를 통해 정보를 전달할 수 있습니까?
이것은 segue에 대한 내 정보입니다. "데이터"는 별도의 파일에있는 구조체입니다.
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
하지만 두 개의 배열이 있는데, 어떻게해야할지 모르겠습니다. 또한이 정보는 작동하지 않습니다. 전달 된 정보가 0이고 앱이 다운된다고합니다. 두 배열에는 정보가 추가되어 있습니다.
이 전체 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