简体   繁体   English

didSelectItemAtIndexPath没有在ios swift中调用

[英]didSelectItemAtIndexPath is not calling in ios swift

When I just select/tap on item, didSelectItemAtIndexPath method was not called. 当我只选择/点击项目时,未调用didSelectItemAtIndexPath方法。 But when I long press on item then didSelectItemAtIndexPath it is calling work perfectly. 但是,当我长按项目然后选择了didSelectItemAtIndexPath它正在完美地调用工作。 Why it happens like this. 为什么会这样。 What should I did wrong? 我该怎么办?

I added collection view as follows 我添加了如下的集合视图

collectionview_followers.frame = CGRectMake(0, 50, SCREEN_WIDTH, 150) collectionview_followers.frame = CGRectMake(0,50,SCREEN_WIDTH,150)

    collectionview_followers.delegate = self

    collectionview_followers.dataSource = self

    collectionview_followers.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "FollowersCell")

    collectionview_followers.backgroundColor = UIColor.clearColor()

    collectionview_followers.userInteractionEnabled = true

    collectionview_followers.allowsSelection = true

    view_collectionviewBG.addSubview(collectionview_followers)

and cell contains uiview with image and label 和单元格包含带图像和标签的uiview

确保在super.ViewDidLoad()之前的viewDidLoad方法中设置self.tableView.allowsSelection = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM