書いてみた
[self collectionView:myCollectionView didSelectItemAtIndexPath:selectedIndexPath]
UICollectionViewCell の selected=YES が viewDidLoad にあり、メソッドdidSelectItemAtIndexPath
を実装しましたが、セルが選択されていません。
選択状態は UICollectionViewCell サブクラスの に書きました(void)setSelected:(BOOL)selected
。ビューがロードされた後、手動選択機能が機能します。しかし、ビューの最初の読み込み後にいくつかの項目を自動選択することはできませんでした。
そして、私はコードを書き込もうとしました:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
と
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
、すべてOKではありません。
私はそれが最初に実行されたことを発見しviewDidLoad
、didSelectItemAtIndexPath
その後、 (私が知っている)以前にセルが存在しなかったためcellForItemAtIndexPath
、セルを取得できなかったようです。では、最初のロード後にいくつかのアイテムを選択する方法は?indexPath
cellForItemAtIndexPath
UICollectionView
私の下手な英語でごめんなさい。前もって感謝します。