【发布时间】:2018-03-26 13:15:16
【问题描述】:
大家好,我在选择集合中的单元格时遇到问题。
当然,为了管理选择和取消选择,我提供了委托方法didSelectItemAtIndexPath和didDeselectItemAtIndexPath
一切正常,但我有一个我无法解决的问题。简而言之,当我选择一个单元格时,我希望能够通过重新选择单元格本身来取消选择最后一个单元格......例如
我将为单元格命名,以便您更好地理解我的问题
用户选择单元格“22” 以取消选择它。我希望用户再次重新选择单元格 22 并取消选择它。
我尝试使用allowMultipleSelection = YES,这似乎在我更喜欢的系统中,但问题是未重新选择单元格,选择了所有其他条目,所以这是错误的......我该如何解决这个问题问题……??
这是我用于选择和取消选择单元格的代码
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
SmartCalendarDayCell *calendarDayCell = (SmartCalendarDayCell *)[self.dayCollectionView cellForItemAtIndexPath:indexPath];
calendarDayCell.day.textColor = [UIColor colorWithHexString:@"#D97E66" setAlpha:1];
}
-(void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
SmartCalendarDayCell *calendarDayCell = (SmartCalendarDayCell *)[self.dayCollectionView cellForItemAtIndexPath:indexPath];
calendarDayCell.day.textColor = [UIColor lightGrayColor];
}
【问题讨论】:
标签: ios uicollectionview uicollectionviewcell nsindexpath