前のセルで何らかのアクションを実行して次のセルに移動すると、コレクションビューセルのラベルが更新されます

Parth Soni

2つのカスタムセルを使用してコレクションビューを実装しました

最初のセルのボタンを押してから、collectionviiewの2番目のセルにスクロールすると、2番目のセル内にあるlabelの値を変更する必要があります。

最初のセルにテキストフィールドがあり、2番目のセルにラベルがあるとします。

最初のセルに値を入力して[次へ]をクリックすると、最初のセルからブロックを呼び出し、collectioviewを2番目のセルにスクロールして、最初のセルのテキストフィールドに入力したラベルの値を設定したいと思います。

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    switch indexPath.item {
    case 0:
        let secondCell = collectionView.dequeueReusableCell(withReuseIdentifier: "secondCell", for: indexPath) as! SecondCell
        secondCell.packages = FindJobVC.subcripDetail.package
        secondCell.moveToNextStep = { textFieldValue in 

    // here I want to change the label text of  CheckoutCell 

            self.cvFindJob.scrollToItem(at: IndexPath(item: indexPath.item + 1, section: 0), at: .centeredHorizontally, animated: true)
            self.cvFindJob.reloadItems(at: [IndexPath(item: indexPath.item + 1, section: 0)])
        }
        return secondCell
   case 1:
        let checkoutCell = collectionView.dequeueReusableCell(withReuseIdentifier: "CheckoutCell", for: indexPath) as! CheckoutCell
        checkoutCell.makePayment = {
            self.makePayment()
        }
        checkoutCell.moveToPreviousStep = {
            self.cvFindJob.scrollToItem(at: IndexPath(item: indexPath.item - 1, section: 0), at: .centeredHorizontally, animated: true)
        }
        return checkoutCell
    }
}
ダースゾーン

「プリフェッチを有効にする」のチェックを外すだけで、準備が整います。

がんばろう

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

Related 関連記事

ホットタグ

アーカイブ