【发布时间】:2016-04-23 16:02:17
【问题描述】:
我有两个 UICollectionView
@IBOutlet weak var collectionView1: UICollectionView!
@IBOutlet weak var collectionview2: UICollectionView!
我正在使用函数分别获取每个集合视图的 indexPath。
func getIndexPathForSelectedCell() -> NSIndexPath?
{
var indexPath:NSIndexPath?
if collectionview1.indexPathsForSelectedItems()!.count > 0 {
indexPath = collectionview1.indexPathsForSelectedItems()![0]
}
return indexPath
}
func getIndexPathForSelectedCell2() -> NSIndexPath?
{
var indexPath2:NSIndexPath?
if collectionView2.indexPathsForSelectedItems()!.count > 0 {
indexPath2 = collectionView2.indexPathsForSelectedItems()![0]
}
return indexPath2
}
我正在为单元格触摸执行 segue,如下所示。
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
if let indexPath = getIndexPathForSelectedCell()
{
let DealsdetailViewController = segue.destinationViewController as! DealsDetailViewController
DealsdetailViewController.Dealsdata = Dealsdata[indexPath.row]
}
else if let indexPath2 = getIndexPathForSelectedCell2()
{
let ContainerviewController = segue.destinationViewController as! ContainerViewController
ContainerviewController.BTdata = BTdata[indexPath2.row]
}
}
如果我在第一个集合视图中单击一个单元格,当我在第二个集合视图中单击一个单元格时,segue 会正确执行
我有错误 在
let DealsdetailViewController = segue.destinationViewController as! DealsDetailViewController
这是第一个if语句条件值,我卡在这里
请帮助我,如何处理在每个集合视图上单击单元格时执行两个 segue。
【问题讨论】:
标签: swift uicollectionview segue uicollectionviewcell uistoryboardsegue