我正在尝试抓取我在collectionView didSelectItemAtIndexPath
函数中点击的单元格的标记号。
这是我的代码:
标签设置:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
....
cell.tag = [theID intValue]; //SET VIDEO ID
...
}
标签是必需的,因为它是我用来发送到我的服务器以获取信息的ID
我的选择器:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"%@",[[collectionView viewWithTag:indexPath] class]);
}
我们的想法是根据cell's
indexPath
代码
不确定我是如何做到这一点的。
建议吗?想法?
答案 0 :(得分:3)
使用UICollectionView
' s cellForItemAtIndexPath:
,您可以获取单元格对象。
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
NSInteger tag = cell.tag;
NSLog(@"%d",tag);
}