-1

I am using a collection view to present the data loaded from firebase. I am not using any sort of embedded navigation controller, just the normal viewcontroller.

Now, whenever I change my view and come back, all data is reloaded and the controller starts from scratch. I actually want it to be on the cell it was left of and how it was left.

I have check plenty of articles and sources on the internet, but most of them are about the embedded navigation controller.

Can anyone guide me on how exactly can I achieve this without using the embedded navigation controller?

Please let me know if anymore information is required. I'll be quite prompt.

Aakash Dave
  • 866
  • 1
  • 15
  • 30

1 Answers1

1

I thinks it depends on where you reload your collection view data. You said

Now, whenever I change my view and come back

Did you present your next view controller or push view controller from view controller where your collection view exists? if yes, you may use dismiss or pop view controller to come back.

When you come back to view controller where your collection view exists, viewWillAppear and viewDidAppear method will be called.

Did you fetch data from firebase in one of these method? if yes all the data will be reloaded unless you made boolean flag not to load again.

Hope this help you.

Rurouni
  • 963
  • 10
  • 31
  • Hmm. Makes sense. I do definitely have functions being called from one of these. I am going to check this and be back If I am stuck. Thanks for the reply. I will update you real soon. – Aakash Dave Dec 21 '18 at 03:50
  • I still doubt of the possibility without a navigation controller. If as a result of this "navigation" you are doing deallocates the viewcontroller, it will be initialized from scratch when you come back to it. A navigation controller stacks view controllers in order while not deallocating them. This coupled with @Rurouni answer will help you solve the problem – jms Dec 21 '18 at 04:13