Some suggestions
sdrpa opened this issue · 1 comments
sdrpa commented
In the init:
_oldSelectedTabBarItemIndex = -1; // When nothing is selected
- (void)infiniteTabBar:(InfiniteTabBar *)tabBar didSelectItemWithTag:(int)tag {
// Prevent to fire didSelectItemWithTag: if the item is already selected
if (tag == _oldSelectedTabBarItemIndex) {
return;
}
// Sometimes last seelcted item was on second tabbar but by default always first tabbar will be displayed on load, we need to scrol to tabbar which contains selected item. I need this because app. remembers last selected tag on exit and restores state on load ..
NSInteger tabItemsPerTabBar = 5;
if (tag / tabItemsPerTabBar >= 1.0) {
int indexOfTabBarForSelectedItem = (int)(tag / tabItemsPerTabBar);
if (self.tabBar.currentTabBarTag != indexOfTabBarForSelectedItem) {
[self.tabBar scrollToTabBarWithTag:indexOfTabBarForSelectedItem animated:NO];
}
}
_oldSelectedTabBarItemIndex = tag;
}
}
I did this in my viewController which is InfiniteTabBarDelegate. May be this should be done as part of InfiniteTabBar implementation. Anyway InfiniteTabBar is a great component. Thank you.
iosdeveloper commented
Feel free to fork and request a pull ;)