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

有帮助吗?

解决方案

  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.

其他提示

  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.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top