I have added a separate UITabbar to a viewcontroller. Made all the necessary outlets. Home viewcontroller has the tabbar in it. What i want it If i click the first button there should be no change but if click the second tabbar item it should show the second screen.
func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem){
switch item.tag {
case 1:
if sampleOne == nil {
var storyboard = UIStoryboard(name: "Main", bundle: nil)
sampleOne = storyboard.instantiateViewController(withIdentifier: "s1") as! SampleOneViewController
}
self.view.insertSubview(sampleOne!.view!, belowSubview: self.sampleTabBar)
break
case 2:
if sampleTwo == nil {
var storyboard = UIStoryboard(name: "Main", bundle: nil)
sampleTwo = storyboard.instantiateViewController(withIdentifier: "s2") as! SampleTwoViewController
}
self.view.insertSubview(sampleTwo!.view!, belowSubview: self.sampleTabBar)
break
default:
break
}
But it loads Homeviewcontroller first then it shows the other viewcontroller.
Now how should i set the homeviewcontroller(which has uitabbar in it) as first viewcontroller.