所以我的应用程序是一个基本的音乐库,当用户点击专辑时, View 会切换到一个引用 ID,该 ID 与专辑相关联,只提供艺术家和歌曲等基本信息。当我运行应用程序时,某些东西丢失了,什么也没有发生,或者应用程序崩溃了。
var names=[String]()
var identities = [String]()
var ButtonAudioPlayer = AVAudioPlayer()
override func viewDidLoad(){
names = ["That's The Spirit", "Chocolate Starfish and the Hot Dog Flavored Water", "IOWA"]
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int)-> Int{
return names.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)-> UITableViewCell{
let cell = tableView.dequeueReusableCellWithIdentifier("Cell")
cell?.textLabel!.text = names [indexPath.row]
return cell!
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let vcName = identities[indexPath.row]
let viewController = storyboard?.instantiateViewControllerWithIdentifier(vcName)
self.navigationController?.pushViewController(viewController!, animated: true)
}
最佳答案
您需要在 viewDidload 中创建一个身份 并在 View Controller 中有这些引用。 前任。身份 = ["a", "b"]
关于IOS 缺少一些切换引用或其他东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37057552/