I've followed this tut https://spin.atomicobject.com/2015/09/02/switch-container-views/ to create a segmented controller with two container views.
My problem is that the when app is launched first view is not shown. Clicking on second segment also doesn't do anything.
Only after third clicks and onwards these views are loaded.
It's strange as I've downloaded the code in tut and it works perfectly fine but it doesn't work when I create my own project and follow exactly same steps as shown in above tut.
Can anyone point me what I might be missing?
See the attached screenshot. When I run the app First segment is the default segment but in the view below it loads second segment.
Next when I click in Second it doesn't do anything.
Only after third click and onwards it loads correct segments.
You can try added this code after method viewDidLoad, for show animation after app loaded.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animateWithDuration(0.5, animations: {
self.containerViewA.alpha = 1
self.containerViewB.alpha = 0
}
}