【发布时间】:2015-07-18 00:55:28
【问题描述】:
我在集合视图中显示数据,我知道如何使用 prepareForSegue 函数传递数据,但我试图让应用程序根据单元格属性数据确定要使用哪个 segue。 (每个 segue 都转到不同的视图控制器以显示相关信息。)
例如
如果 cell.type 等于"1",则执行segueOne,如果它是"2" 类型,则执行segueTwo。
我试图做这样的事情;
func collectionView(collectionView: UICollectionView, shouldSelectItemAtIndexPath indexPath: NSIndexPath) -> Bool {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! CollectionViewCell
if cell[indexPath].type = "1" {
performSegueWithIdentifier("showPage1", sender: self)
} else if self.cell[indexPath].type = "2" {
performSegueWithIdentifier("showPage2", sender: self)
} else { println("error when selecting cell to segue") }
}
但是我得到一个错误;
'CollectionViewCell' 没有名为 Subscript 的成员
有人有什么想法吗?
【问题讨论】:
-
这方面有进展吗?
-
@QED 是的,我今天回到这个问题并接受了答案。我确实修改了代码。检查下面
标签: ios swift core-data uicollectionview segue