azurechen / ACTabScrollView

A fancy Menu and Pager UI extends UIScrollView with elegant, smooth and synchronized scrolling tabs.
MIT License
115 stars 35 forks source link

How to reload table view/collection view to the top!? #21

Open barHopperSF opened 6 years ago

barHopperSF commented 6 years ago

Hi Azure, Great little app you created. I am using the code in my project but I was wondering if there is any way to reload table view / collection view to the top when I change tabs? I have 4 separate view controllers that corespondent to 4 different tabs. 2 are with table view and 2 have collection view. Everything works great. The only issue I have is when I scroll half way down in let say view controller 1 and move to view controller 2 when I come back to view controller 1 the table view stays on the same spot. I would like to make it go all the way to the top. I have try to use this function in each view controller:

override func viewWillAppear(_ animated: Bool) { collectionView.setContentOffset(CGPoint.zero, animated: true) }

It works for one tap but not for the others. I was wondering if there is any properties I can change in ACTabScrollView.swift file to make it work. Thanks again in advance.

barHopperSF

saito-sv commented 6 years ago

I know this was a long time but just giving it a shot. @barHopperSF this is pretty much the behavior of the viewcontroller being in memory, when you come back to the previous controller whatever the state was will always stay the same, the viewWillAppear(_ animated:) should've done the magic. can you check if this function gets called each time to come back to the view controller?