What is the best location to create the segmented control and handle its events?
I have done it in two places so far:
hypnosisViewController: loadView and
In both cases, the SC is added as a subview of the HypnosisView.
Both locations work but the events are sent to a different place: either the hvc or the hv.
Again, to the user they look the same.
Originally I put it in the View because I thought the view should handle all the logic for drawing itself.
Then I thought about the events being “logic” and moved it to the ViewController (which is what most answers here did). Although the HypnosisView already has code for handling events (touch) from a previous example.
Then I started to experiment with placing the SC at the bottom of the view and noticed a problem when I rotate the device.
On rotation, the view does not redraw itself so the circles look stretched and the segmented control is not shown.
We had already connected the tap event so that causes a redraw but it still does not show the segmented control. i think that is because the SC is created in the viewController loadView which is not called when the View redraws,
This makes me think the SC should be created and handled in the View not in the ViewController.