简体   繁体   中英

didSelectItemAtIndexPath is not calling in ios swift

When I just select/tap on item, didSelectItemAtIndexPath method was not called. But when I long press on item then didSelectItemAtIndexPath it is calling work perfectly. 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.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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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