Question

I am developing an app which needs an screen where actually there are 3 screens, I mean, there is a uisegmentedcontrol and, when I push in the options, the content of the screen changes. I know how to do it but I think that there is a more correct way. I put all of the components of the all screens in the screen , and depend on the click in the segmentecontrol I hide or not the elements, but is there a way to do it better? cleaner? something like to have 3 screens independently, with the logic independently as well, and I load each one when I click in the segmentedcontrol?

Thank you in advance

Was it helpful?

Solution

  1. Make three different UIView objects.
  2. Add your components as subviews of those views.
  3. Show one of the three views depending on the selected segment index.

OTHER TIPS

  1. Make three different UIViewController, so that each one will only contain the logic for its own view.
  2. Each VC will contain a UISegmentControl with different default value.
  3. When user click on UISegmentControl, you switch the UIViewControllers instead of UIViews, which makes it looks the same.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top