ios - Change UINavigationbar title according to UICollectionView Cell -


im trying change title of uinavigationbar title according uicollectionview cell indexpath.row, have horizontal uicollectionview cells photo sliding-content (as photo app in ios).

what trying achieve when move indexpath.row example 1 2 change title having 1 issue, i've placed following code in cellforitematindexpath or willdisplaycell :

self.title = "\(indexpath.row+1) of 2" 

this code works fine has 1 issue, when start dragging next cell return i, title changed 2 still in 1 ! annoying !

i've tried place code in scrollviewdidenddecelerating has same issue, started dragging changed mind stay on cell 1 method says okey end dragging, title again changes 2 still in one.

i need since if still don't have change title, if in next cell change title.

it happening because method cellforitematindexpath called prepare second item, first cell still in memory , method cellforitematindexpath not called when return first. try this:

-(void)scrollviewdidenddecelerating:(nonnull uiscrollview *)scrollview {         float currentpage = self.collectionview.contentoffset.x / self.collectionview.frame.size.width;         nslog(@"current page: %f", ceil(currentpage)); } 

don't forget add uiscrollviewdelegatein collectionviewcontroller.h


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -