- Make three different
UIView
objects. - Add your components as subviews of those views.
- Show one of the three views depending on the selected segment index.
Make an screen with 3 screens inside and uisegmentedcontrol
-
22-07-2023 - |
题
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
解决方案
其他提示
- Make three different UIViewController, so that each one will only contain the logic for its own view.
- Each VC will contain a UISegmentControl with different default value.
- When user click on UISegmentControl, you switch the UIViewControllers instead of UIViews, which makes it looks the same.
不隶属于 StackOverflow