How can I select programmatically a UITabbarController
item from a UISegment
from other ViewController
?
ViewcontrollerA
has a UISegmentControl
and a ContainerView
UITabbarControllerB
is embedded in the ContainerView
from ViewControllerA
and has itself two ViewControllers
VCItemA
and VCItemB
.
Now the problem is, I can't change the VCItem
from UITabbarControllerB
via the SegmentControl
from UIViewcontrollerA
.
You can try inside ViewcontrollerA
( Swift)
if let tab = self.children.first as? UITabbarControllerB {
tab.selectedIndex = // 0 or 1
}
( Objective - C )
if ([self.childViewController.firstObject isKindOfClass:UITabbarControllerB.self])
UITabbarControllerB* tab = (UITabbarControllerB*) self.childViewController.firstObject;
tab.selectedIndex = // 0 or 1
}