我試着寫如何在第一次加載後在UICollectionView中選擇一些項目?
[self collectionView:myCollectionView didSelectItemAtIndexPath:selectedIndexPath]
和UICollectionViewCell的選擇= YES在viewDidLoad中,才實現的方法didSelectItemAtIndexPath
,但細胞無法選擇。
我在UICollectionViewCell子類的(void)setSelected:(BOOL)selected
中編寫了選定的狀態。視圖加載後,手動選擇功能起作用。但是我不能讓它在視圖第一次加載後自動選擇一些項目。
我試着寫碼:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
和
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
,都不確定。
我發現它第一次運行viewDidLoad
和didSelectItemAtIndexPath
,然後cellForItemAtIndexPath
,好像,我無法cellForItemAtIndexPath
之前獲得的indexPath
細胞(我知道),因爲在此之前,該小區是不存在的。那麼如何在第一次加載後在UICollectionView
中選擇一些項目?
對不起,我英文很差。提前致謝。
謝謝!我已經完成了!我總是使用錯誤的代碼:[self collectionView:_tagsCollectionView didSelectItemAtIndexPath:selectedIndexPath]並試圖將它放在任何地方,而不是selectItemAtIndexPath,因此總是不起作用。 – zgjie 2013-03-05 16:39:43
當我的視圖加載時,這種方法對我很有幫助。但在我看來,我有拇指自動選擇 – bashan 2013-10-14 18:42:57
什麼是你的問題?原來的問題是關於視圖的第一個負載。 – SAE 2013-10-14 23:04:11