我有一個UITableview
。其中一個UITableViewCell's
是UICollectionview
,實例名稱爲「amenityView」。如下所示,UICollectionViewDelegate
和UICollectionViewDataSource
設置在storyboard
中。以下方法被調用並且數據按預期填充。collectionView:didSelectItemAtIndexPath:沒有被調用
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- (UICollectionViewCell *)collectionView:(UICollectionView *)collection cellForItemAtIndexPath:(NSIndexPath *)indexPath
但是,下面的方法並沒有被調用時,我選擇包含在UICollectionView
的UICollectionViewCell
。我錯過了什麼?
-(void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
-(void) collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
UPDATE: 返回YES在該方法中collectionView:shouldSelectItemAtIndexPath:
將調用下面兩種方法。至少這是我的缺失。希望這將有助於一些機構...
是[「'.allowsSelection'」](https://developer.apple.com/library/ios/documentation/uikit/reference/UICollectionView_class/Reference/Reference.html#//apple_ref/occ/instp/UICollectionView/allowedSelection)爲你的收藏視圖設置爲YES? –
@MichaelDautermann。感謝您的答覆。 「.allowsSelection」設置爲「YES」。 – Loozie
它所坐的表格視圖單元格是否允許用戶交互或選擇單元格本身? –