didSelectItemAtIndexPath没有在ios swift

时间:2015-12-01 07:04:27

标签: ios swift uicollectionview uicollectionviewcell

当我选择/点按项目时,未调用didSelectItemAtIndexPath方法。但是,当我长按项目然后didSelectItemAtIndexPath时,它正在完美地调用工作。为什么会这样。我该怎么办?

我添加了集合视图,如下所示

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)

和单元格包含带图像和标签的uiview

1 个答案:

答案 0 :(得分:0)

确保在import package_v1 as package之前的self.tableView.allowsSelection = true方法中设置viewDidLoad