Ios 通过Swift中的PrepareForsgue将数据从UICollectionView传递到UITableView

Ios 通过Swift中的PrepareForsgue将数据从UICollectionView传递到UITableView,ios,swift,uitableview,uicollectionview,segue,Ios,Swift,Uitableview,Uicollectionview,Segue,输出 事件ID为:圆圈 无法将“ThisLondon.ViewController”(0x9c338)类型的值强制转换为“UICollectionViewCell”(0x39dbd1a0)。 (lldb) 是的,正在输出“圆”,这就是我选择的,很好,尽管我不能让它通过segue传递到tableView 这是我的密码: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue

输出 事件ID为:圆圈 无法将“ThisLondon.ViewController”(0x9c338)类型的值强制转换为“UICollectionViewCell”(0x39dbd1a0)。 (lldb)

是的,正在输出“圆”,这就是我选择的,很好,尽管我不能让它通过segue传递到tableView

这是我的密码:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "selectedTube" {
        let detailViewController = segue.destinationViewController as! tubeDetailsTableViewController

        if let indexPath = collecView.indexPathForCell(sender as! UICollectionViewCell) {
            detailViewController.selectedTube = stationArray[indexPath.row]
        }
    }
}

既然有一个cast正在那里发生(涉及到提到的两种类型),我想
sender
就是视图控制器本身。。。您可以尝试放置断点并检查其值。嗯,很抱歉,我不明白,第一个视图是UICollectionView,我正试图传递给UITableView的数据您可以分享一些关于segue是如何实际触发的信息吗?如果我使用此函数,然后thisTube将首先等于“Circle”,但随后变为nil
func collectionView(collectionView:UICollectionView,didSelectItemAtIndexPath indexPath:NSIndexPath){print(“用户点击:\(indexPath.row)”)thisTube=stationArray[indexPath.row]NSLog(“事件ID为:\(thisTube)”)performsguewithidentifier(“selectedTube”,sender:self)}
我成功地做到了,但我没有从UICollectionViewCell获取信息