2

I am trying to use the same side menu for 2 viewcontrollers on the sidemenu demo project. See image setup of menu using their demo project

I am able to set up the 2 cells on the menu which will open the 2 VCs base on what i tap but trying to find out if i can keep the 'state of data' on the VC.

To know how many times the VCs are loaded/appear into the view, i inserted 'print to console' into viewdidload and viewdidappear of the 2 VCs. I set VC 1 as the root view controller. If I tab VC 1 on the menu, it will only 'print viewdidload+viewdidappear' once and just 'print viewdidappear the next time I tab it. This is correct and what i need similar like a 'tab controller feature'. However, for VC 2, it will print 'viewdidload+viewdidappear' all the time which means the view keeps 'reloading'. But i would like to keep the 'state of data' just like VC1.

So if i switch VC 2 as the rootviewcontroller, then VC 2 will keep the 'state of data' and VC 1 will not. I tried 'menuPushStyle: MenuPushStyle = .defaultBehavior, - popWhenPossible, preserve, preserveAndHideBackButton' but can't make it work.

0 Answers0