我UICollectionView与自定义单元格(XIB文件),我管理显示的CollectionView,但我不管理,当我与功能的电池接头检测:斯威夫特的CollectionView didSelectItemAtIndexPath不工作
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){
通常,我设法做到这一点,但这次我不知道为什么它不起作用。其实我使用这个豆荚“https://cocoapods.org/pods/SACollectionViewVerticalScalingFlowLayout”
我的代码是:
class ProjectsController: UIViewController {
@IBOutlet weak var collectionViewGridFormat: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
collectionViewGridFormat.registerNib(UINib(nibName: "ProjectsGridFormatCell", bundle: nil), forCellWithReuseIdentifier: "cellProjectGrid")
...
}
}
extension ProjectsController: UICollectionViewDataSource, UICollectionViewDelegate {
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 30
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell : ProjectsGridFormatCell = collectionView.dequeueReusableCellWithReuseIdentifier("cellProjectGrid", forIndexPath: indexPath) as! ProjectsGridFormatCell
cell.lblProjectName.text = "Test project"
return cell
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){
print("aa")
}
}
但是,当我在一个小区,“打印(” AA“),”轻点不显示。
我给了足够的信息吗? :)
感谢您的帮助! :d
问候,
您是否将视图控制器设置为集合视图的委托?您需要同时设置 - 委托和数据源。 – almas