0

there are different conditions for same design file. i can't use if-else in same class file to differentiate them. because manage all conditions are difficult. is there any way to change class at dynamic time.

dinesh sharma
  • 399
  • 4
  • 20
  • 1
    Have a look here on how to do it with NIB files. https://stackoverflow.com/a/29147012/4543629 – LGP Mar 21 '18 at 12:59
  • 1
    Look here on doing it with Storyboard. https://stackoverflow.com/a/29220057/4543629 – LGP Mar 21 '18 at 12:59

2 Answers2

0

Yes, we can set class using Xib. But from my research i didn't find any way to change storyboard class dynamically. I found other way to reuse the view like using container view. following link shows how can we reuse storyboard view. Diego Lavalle describe it on medium.

and you can read about container view at here.

dinesh sharma
  • 399
  • 4
  • 20
0

I think you can use a master view controller and can load different view controllers as child based on some condition.

For example in Master View controller you can use UIsegmentedControl and based on the option the user chooses, you can show different view controllers.

Refer the following for implementing the same.

https://medium.com/@Dougly/creating-a-custom-view-controller-navigation-interface-programmatically-swift-3-1-8c9e582cdb30