bryankeller / BLKFlexibleHeightBar

Create condensing header bars like those seen in the Facebook, Square Cash, and Safari iOS apps.
MIT License
3.04k stars 338 forks source link

snapping issue while switching bewteen UICollectionViews #30

Closed liuxuan30 closed 9 years ago

liuxuan30 commented 9 years ago

I have two tabs, each tab contains a UICollectionView, and a BLKHeightBar as the shared title view. snap is enabled and set to 0.5 threshold.

tab 1 contains 6 cells and tab 2 containts 20 cells, so normally, tab 1 will always bounce back to progress 0, while tab 2 can snap to 1 and 0.

When I switch to tab 2, scroll tab 2 and make it snap to progress 1, and then I switch to tab 1, while the height bar stays at progress 1,

Then when I switch again back to tab 2, now I cannot snap tab 2 back to progress 0. When I see the self.flexibleHeightBar.progress is set to 0, after that it is snapping back to progress 1, which is wrong. I feel it should not snap to progress 1 while self.flexibleHeightBar.progress == 1.

It seems like some variable is not updating the current scroll view properties? How could I continue debug it and fix it?

liuxuan30 commented 9 years ago

when I tried to set each tab scroll view(UICollectionView to be correct), and I found that I maybe did it incorrectly: targetCollectionView.contentInset = UIEdgeInsetsMake(self.navigationBar.frame.size.height, 0, 20, 0);

The idea is I want to keep the scroll view contentInset consistent, so when the height bar is at minimum height, I still get the correct Inset.

I am trying to use contentOffset to adjust the offset, instead of changing contentInset.

The contentInset I think should always be targetCollectionView.contentInset = UIEdgeInsetsMake(self.navigationBar.maximumBarHeight, 0, 20, 0);