[英]UICollectionView didselectitematindexpath delegate?
[英]Will UICollectionView change the cell's selected property to true before sending didSelectItemAtIndexPath delegate method?
上面已經描述了這個問題。 我是否必須在委托方法didSelectItemAtIndexPath中調用UICollectionView的selectItemAtIndexPath方法,還是UICollectionView已經為我做到了?
是。 在調用didSelectItemAtIndexPath
,所選屬性已經設置為TRUE
。
要驗證,只需添加:
NSLog(@"selected: %i", [collectionView cellForItemAtIndexPath:indexPath].selected);
到didSelectItemAtIndexPath
方法,您將看到它返回true
(1)
有willSelectRowAtIndexPath方法和didSelect ...方法。 調用willSelect ...方法時, 不會更改選擇,並且會在did-select上進行更改。 (如果需要,willSelectRowAtIndexPath可讓您有機會在選擇發生之前更改/取消選擇。)
這是iOS框架中的一個強大的命名約定。 緊張的方法名中的動詞告訴您何時調用該方法是否已經發生了事件,但(如viewWillAppear
和viewDidAppear
該viewWillAppear
顯示一個視圖之前方法被調用, viewDidAppear
被調用后顯示的視圖。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.