ライブラリをUICollectionView
使用して作業しています。PSTCollectionView
ユーザーが をタップして画像を選択および選択解除できるグリッドを作成する必要がありますUICollectionViewCell
。セルが選択されている場合、画像のようなcheckBoxを表示する必要があります。セルが選択解除されている場合は uncheckedBox 画像。チェックボックスの画像を選択cell
して表示できます。選択を解除することもできます。しかし、 next を選択するcell
と、前に選択解除
されたcell
ものも選択され、checkBox イメージが表示されます。これは、UICollectionViewCell
サブクラスで宣言したメソッドです
-(void)applySelection{
if(_isSelected){
_isSelected=FALSE;
self.contentView.backgroundColor=[UIColor whiteColor];
self.selectImage.image=[UIImage imageNamed:@"unchecked_edit_image.png"];
}else{
_isSelected=TRUE;
self.contentView.backgroundColor=[UIColor whiteColor];
self.selectImage.image=[UIImage imageNamed:@"checked_edit_image.png"];
}
}
didSelectItemAtIndexPath
そして、
これが私のコードですdidDeselectItemAtIndexPath
- (void)collectionView:(PSTCollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"didSelect method called");
FriendImageCell *cell = (FriendImageCell*)[imageGrid cellForItemAtIndexPath:indexPath];
[selectedImages addObject:[[list objectAtIndex:indexPath.item] objectForKey:@"thumbnail_path_150_150"]];
[cell applySelection];
}
- (void)collectionView:(PSTCollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"did deselect called");
FriendImageCell *cell = (FriendImageCell*)[imageGrid cellForItemAtIndexPath:indexPath];
[selectedImages removeObjectAtIndex:indexPath.item];
[cell setSelected:NO];
[cell applySelection];
}
誰かが私のコードの何が問題なのかを理解してもらえますか? 私が何か間違ったことをしているなら、私を正してください。スタックオーバーフローで多くの回答を試みましたが、何も機能しませんでした。どんな助けでも大歓迎です。前もって感謝します。