ios - UICollectionView reloading not properly -


i have kind of requirement, if user has selected 1 have display images (which in collection view cell) rotating @ 90 degree , if user had selected 4 have display images round. selection 2 , 3 display image is.
written below code.

- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath {     filtercell *cell = (filtercell *)[collectionview dequeuereusablecellwithreuseidentifier:@"filtercell" forindexpath:indexpath];     if (!cell) {         cell = [[filtercell alloc] init];     }         if (filterscreen==1) {             cell.imgview.image = [collectionimage objectatindex:indexpath.row];             cell.imgview.transform = cgaffinetransformmakerotation(m_pi_2);         }         else if (filterscreen==2) {             cell.imgview.image = [uiimage imagenamed:[nsstring stringwithformat:@"filter_%ld",(long)indexpath.row]];         }         else if (filterscreen==3) {             cell.imgview.image = [uiimage imagenamed:[nsstring stringwithformat:@"motiontitle_contents_%ld",(long)indexpath.row]];         }         else if (filterscreen==4) {             cell.imgview.image = [uiimage imagenamed:[nsstring stringwithformat:@"bgm_%ld",(long)indexpath.row]];             cell.imgview.layer.cornerradius = cell.imgview.frame.size.height /2;             cell.imgview.layer.maskstobounds = yes;         }     return cell; } 

and on selection 1,2,3 or 4 i'm reloading collection view.

the problem if user selected 4 after selecting 1 of images after displays rotated , after if user selects 2 or 3 images rotated , images circle. have tried delete section before reloading per mention here app crashes , log

*** assertion failure in -[uicollectionview _enditemanimations], /sourcecache/uikit/uikit-3318.93/uicollectionview.m:3917

reloading code below:

nsindexset *indexset = [nsindexset indexsetwithindexesinrange:nsmakerange(0,0)]; [filtercollectionview deletesections:indexset]; [filtercollectionview reloaddata]; 

update: if tried using
nsindexset *indexset = [nsindexset indexsetwithindexesinrange:nsmakerange(0,1)];
getting

*** assertion failure in -[uicollectionview _enditemanimations], /sourcecache/uikit/uikit-3318.93/uicollectionview.m:3901

can me solve this?

okay took while me understand problem.

first, solution trying wrong. want reload section delete instead (try reloadsections instead).

however, won't solve problem either. cells reused , never reset transform property. try this:

- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath {     filtercell *cell = (filtercell *)[collectionview dequeuereusablecellwithreuseidentifier:@"filtercell" forindexpath:indexpath];     if (!cell) {         cell = [[filtercell alloc] init];     }     cell.imgview.transform = cgaffinetransformidentity;     cell.imgview.layer.cornerradius = 0;     cell.imgview.layer.maskstobounds = no;          if (filterscreen==1) {             cell.imgview.image = [collectionimage objectatindex:indexpath.row];             cell.imgview.transform = cgaffinetransformmakerotation(m_pi_2);         }         else if (filterscreen==2) {             cell.imgview.image = [uiimage imagenamed:[nsstring stringwithformat:@"filter_%ld",(long)indexpath.row]];         }         else if (filterscreen==3) {             cell.imgview.image = [uiimage imagenamed:[nsstring stringwithformat:@"motiontitle_contents_%ld",(long)indexpath.row]];         }         else if (filterscreen==4) {             cell.imgview.image = [uiimage imagenamed:[nsstring stringwithformat:@"bgm_%ld",(long)indexpath.row]];             cell.imgview.layer.cornerradius = cell.imgview.frame.size.height /2;             cell.imgview.layer.maskstobounds = yes;         }     return cell; } 

Comments