点击展开UICollectionViewCell

时间:2019-04-10 19:21:00

标签: ios swift uicollectionview

我有UICollectionView,它可以垂直向上滚动,并且我想改变水龙头的高度。在默认状态下,单元格的高度为屏幕高度的2/3。我尝试了以下操作:

override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let cell = collectionView.cellForItem(at: indexPath)
            if let cell = cell as? TutorialCell {
                let attribute = layout.layoutAttributesForItem(at: indexPath)
                attribute?.frame = CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.size.width,
                                               height: UIScreen.main.bounds.size.height)
                collectionView.reloadItems(at: [indexPath])

            }
        print(indexPath.row)
    }

但是它不起作用。

1 个答案:

答案 0 :(得分:1)

您可以通过 AdColonyAppOptions options = new AdColonyAppOptions() .setGDPRConsentString(consent) .setGDPRRequired(true) .setUserID(FirebaseAuth.getInstance().getCurrentUser().getDisplayName()) .setKeepScreenOn(true); AdColony.configure(this,options, "app131470c541f24230b8", "vz254cb09b88674492aa"); AdColonyUserMetadata metadata = new AdColonyUserMetadata() .setUserAge(26) .setUserEducation(AdColonyUserMetadata.USER_EDUCATION_BACHELORS_DEGREE) .setUserGender(AdColonyUserMetadata.USER_MALE); // Ad specific options to be sent with request adOptions = new AdColonyAdOptions().setUserMetadata(metadata); 方法UICollectionViewDelegateFlowLayout

实现此目标

声明变量

sizeForItemAt

在您的var selectIndex: Int = -1 中添加

didSelectItemAt

override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { self.selectIndex = indexPath.row collectionView.reloadData() } 添加扩展名

UICollectionViewDelegateFlowLayout
相关问题