nscollectionviewitem - NSCollectionView with different item types -
accordingly apple documentation can use multiple item types in single nscollectionview, when it, problem. can't remove items.
a single collection view can support multiple item types, each own distinct appearance, , can mix , match item types in same collection view if want.
my code snippet
- (nscollectionviewitem *)collectionview:(nscollectionview *)collectionview itemforrepresentedobjectatindexpath:(nsindexpath *)indexpath { nsinteger index = indexpath.item; dataitem * item = [self.data itemat:index]; if (item.type == itemtype1) { typeitemcontroller1 * itemcontroller = [collectionview makeitemwithidentifier:@"typeitemcontroller1" forindexpath:indexpath]; [itemcontroller updatewithindex:index]; return itemcontroller; } else { typeitemcontroller2 * itemcontroller = [collectionview makeitemwithidentifier:@"typeitemcontroller2" forindexpath:indexpath]; [itemcontroller updatewithindex:index]; return itemcontroller; } } -(void)collectionview:(nscollectionview *)collectionview removeitemsat:(nsset<nsindexpath*>*) paths { (nsindexpath * path in paths) { [self.data removeitemat:path.item]; } [[collectionview animator] deleteitemsatindexpaths:paths]; }
if have items different types in nscollectionview , have removed 1 of them, item (removed) still displayed on screen. can't interact it, displayed on screen.
if items have same type, problem doesn't occur.
what i'm doing wrong?
Comments
Post a Comment