1
我有像网格视图在uicollectionview中的多个图像。我想一次选择多个图像,但不能使用这个代码。请给任何一个关于此代码的想法。在uicollectionview中的多个选择不工作在ios
我已经试过这段代码但不工作。
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath: (NSIndexPath *)indexPath
{
NSMutableArray *indexPaths = [NSMutableArray arrayWithObject:indexPath];
if (self.selectedItemIndexPath)
{
// if we had a previously selected cell
if ([indexPath compare:self.selectedItemIndexPath] == NSOrderedSame)
{
// if it's the same as the one we just tapped on, then we're unselecting it
self.selectedItemIndexPath = nil;
}
else
{
// if it's different, then add that old one to our list of cells to reload, and
// save the currently selected indexPath
[indexPaths addObject:self.selectedItemIndexPath];
self.selectedItemIndexPath = indexPath;
}
}
else
{
// else, we didn't have previously selected cell, so we only need to save this indexPath for future reference
self.selectedItemIndexPath = indexPath;
}
// and now only reload only the cells that need updating
[self.collectionView reloadItemsAtIndexPaths:indexPaths];
}
此代码只工作了一个选择的多重选择不工作。 – user3331020
请任何人给这个问题的解决方案。 – user3331020
我已经尝试了很长时间使用谷歌,请任何人给这个问题的解决方案.... – user3331020