IOS缺少切换参考或东西的东西?

时间:2016-05-05 18:18:32

标签: ios swift

因此,我的应用程序是一个基本的音乐库,当用户点击相册时,视图会切换到参考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)


}

2 个答案:

答案 0 :(得分:2)

您需要在viewDidload中创建标识 并在viewcontroller中有那些引用。 恩。身份= [" a"," b"]

答案 1 :(得分:0)

我怀疑你需要检查单元格是否为零,如果是,则创建一个新的UITableViewCell。