【发布时间】:2016-03-10 00:53:46
【问题描述】:
import UIKit
class ActionCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var myLabel: UILabel!
@IBOutlet weak var actionGIF: UIImageView!
@IBAction func actionPressed(sender: AnyObject) {
print(myLabel.text)
Global.actionButtonIndex = myLabel.text!.toInt()! - 1
print(actionGIF.image)
ActionViewController.performSegueWithIdentifier("showActionPreview", sender: nil)
}
}
我正在尝试在用户单击我的收藏视图中的一个单元格后执行 Segue。使用 performSegueWithIdentifier 似乎无法做到这一点。 App Screenshot
【问题讨论】:
-
你没有描述问题。它崩溃了吗?
ActionViewController是什么?是类还是实例? -
使用 UICollectionViewDelegate 协议中指定的 collectionView(didSelectItemAtIndexPath:) 方法,而不是单元格中的操作,除非您需要每个单元格具有不同操作的多个按钮。
-
你解决了吗?我有同样的问题,选择项目对我不起作用,因为我在单元格内有 Cell + 一个按钮,这个按钮的作用与按下单元格不同。
标签: ios swift uicollectionview segue uicollectionviewcell