我目前正在使用AQGridView在我的应用程序上显示一个图片库,但我在选择/取消选择处理方面遇到了问题。
在我的图库视图中插入一个单元格后,我可以选择它
它的方式是,我可以很容易地选择两个单元格,但如果我想取消选择一个,它必须是我没有点击过的那个。我的问题是,我希望能够像tableview编辑模式行为那样选择/取消选择。
所以如果我像这样点击右边的

我不能取消选择它,除非我点击另一个像这样的单元格

然后,我可以像这样取消选择前一个单元格

并返回到未选定的单元格。但是,如果一个单元格是我在我的图库中添加的唯一单元格,我就不能取消选择它。
取消选择/选择工作得很好,这是我不理解的地方。
以下是我的AQGridView didSelectItemAtIndex代码
- (void) gridView:(AQGridView *)gridview didSelectItemAtIndex:(NSUInteger)index {
NSLog(@"SELECT");
GalleryGridViewCell * cell = (GalleryGridViewCell *)[self.gridView cellForItemAtIndex:index];
[cell selectImg:TRUE];
[imgList addObject:cell.image];
//sentImg = plainCell.image;
}以下是我的AQGridView didDeselectItemAtIndex代码
-(void)gridView:(AQGridView *)gridView didDeselectItemAtIndex:(NSUInteger)index
{
NSLog(@"img deselected %@ at index %d", plainCell.image, index);
GalleryGridViewCell * cell = (GalleryGridViewCell *)[self.gridView cellForItemAtIndex:index];
[cell selectImg:FALSE];
if (imgList != nil)
[imgList removeObject:cell.image];
}下面是我为GalleryGridViewCell selectImg添加的方法:(BOOL) selection
-(void) selectImg:(BOOL) selection
{
if (selection == TRUE)
{
[_checkBoxBttn setSelected:TRUE];
[self setSelected:TRUE];
}
if (selection == FALSE)
{
[_checkBoxBttn setSelected:FALSE];
[self setSelected:FALSE];
}
}发布于 2013-08-29 08:35:44
在你的gridView:didSelectItemAtIndex方法中,尝试使用gridView取消选择该项index:索引动画:动画;
这应该可以完成这项工作。
https://stackoverflow.com/questions/17085885
复制相似问题