AXStretchableHeaderTabViewController
AXStretchableHeaderTabViewController copied to clipboard
Select the second sub view controller
What's the recommended way to make the second sub view controller selected after the AXStretchableHeaderTabViewController has loaded?
I added some additional methods to "AXStretchableHeaderTabViewController.m" to add this feature.
-(void)setCurrentViewControllerToIndex:(int)index
{
if(_viewControllers.count > index)
{
[_tabBar setSelectedItem:_tabBar.items[index]];
[self didSelectTabBarItemAtIndex:index];
[self layoutSubViewControllerToSelectedViewController:self.selectedViewController];
}
}
-(void)setCurrentViewControllerToTabName:(NSString *)tabName
{
//search through each tab bar button to find out which one matches the requested page
[_tabBar.items enumerateObjectsUsingBlock:^(UIBarButtonItem *barButton, NSUInteger idx, BOOL *stop)
{
//if the button matches our text
if([barButton.title isEqualToString:tabName])
{
//get the index of this button and set the view controller based on this index
int indexOfButton = (int)[_tabBar.items indexOfObject:barButton];
[self setCurrentViewControllerToIndex:indexOfButton];
//return out of the enumeration, we only expect to find one match
return;
}
}];
}