I’m making an attempt to make an iOS hybrid app, however I am caught on step one;
my app doesn’t present its tab bar like this pic tab bar not present
My debug consequence reveals in UITabBarController the self.tabBar.subviews.subviews is empty when i attempt to traverse it, it throw an exception;error
there’s the code
// AppDelegate.m
- (BOOL)utility:(UIApplication *)utility didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
BaseTabbarViewController *tabbarVC = [[BaseTabbarViewController alloc]init];
self.window.rootViewController = tabbarVC;
[self.window makeKeyAndVisible];
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.tabBar.barTintColor = [UIColor whiteColor];
[self setupChildVC];
self.indexFlag = 0;
}
- (void)setupChildVC {
OKRWebViewController *okrMainVC = [[OKRWebViewController alloc] initWithConfig:@"http://192.168.2.183:8080/OKRMain?enable_bounds=0&hide_scroll_bar=1"];
[self setupTabbarItem:okrMainVC.tabBarItem title:@"main" titleSize:12 titleFontName:@"HeiTi SC" normalTitleColor:[UIColor grayColor] selectedTitleColor:[UIColor purpleColor] normalImage:@"tabbar_about_normal" selectedImage:@"tabar_select2"];
OKRWebViewController *okrMainVC2 = [[OKRWebViewController alloc] initWithConfig:@"http://192.168.2.183:8080/OKRMain?enable_bounds=0&hide_scroll_bar=1"];
[self setupTabbarItem:okrMainVC2.tabBarItem title:@"order" titleSize:12 titleFontName:@"HeiTi SC" normalTitleColor:[UIColor grayColor] selectedTitleColor:[UIColor purpleColor] normalImage:@"tabbar_order_normal" selectedImage:@"tabar_select2"];
BaseNavigationController *navA = [[BaseNavigationController alloc]initWithRootViewController:okrMainVC];
BaseNavigationController *navB = [[BaseNavigationController alloc]initWithRootViewController:okrMainVC2];
self.viewControllers = @[navA,navB];
}
- (void)upAnimationWithIndex:(NSInteger)index {
NSMutableArray *tabBarButtonImageArray = [NSMutableArray array];
for (UIControl *tabBarButton in self.tabBar.subviews) {
if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
for (UIView *imageView in tabBarButton.subviews) { // throw exception
if ([imageView isKindOfClass:NSClassFromString(@"UITabBarSwappableImageView")]) {
[tabBarButtonImageArray addObject:imageView];
}
}
}
}
}
discovered some demos and forked the code however that did not work both, I am unsure if completely different configurations would trigger the problem;
https://github.com/PrincessSmall/TabBarConteollerDemo#tabbarconteollerdemo