コレクションビューを持っていて、didSelectメソッドでコレクションビューからセルを削除しようとしました。以下の方法で成功しました
[colleVIew deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
しかし今、CollectionView Cell.Here からボタン クリックで項目を削除する必要があります。ここでは、indexpath.row のみを取得します。これからアイテムを削除できません。私はこのようにしてみました。
-(void)remove:(int)i {
NSLog(@"index path%d",i);
[array removeObjectAtIndex:i];
NSIndexPath *indexPath =[NSIndexPath indexPathForRow:i inSection:0];
[colleVIew deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
[colleVIew reloadData];
}
ただし、CollectionView をリロードする必要があるため、削除後のセル配置のアニメーションはありません。アイデアを提案してください..事前に感謝します