gpt4 book ai didi

ios - 如何选择 CollectionView 中的最后一个单元格?

转载 作者:行者123 更新时间:2023-11-28 21:43:20 24 4
gpt4 key购买 nike

我有一个包含不同图像的数组,我正在使用“cellForItemAtIndexPath”方法将其中的图像添加到 CollectionView,并且我正在尝试使用“didSelectItemAtIndexPath”方法来确定所选单元格是否是最后一个单元格,但我似乎做对了。任何帮助,将不胜感激!这是我的方法:

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath  {

UICollectionViewCell *cell =[collectionView cellForItemAtIndexPath:indexPath];
if(cell == [PicArray lastObject])
{
NSLog(@"selected last cell");
}

}

最佳答案

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath  {
if ([indexPath.item == PicsArray.count-1]) {
NSLog(@"selected last cell");
}
}

关于ios - 如何选择 CollectionView 中的最后一个单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31235621/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com