UITabBarController shows multiple tabs selected

When I init my Tab bar, it highlights more than one tab- this corrects itself after selecting them. how can I get it to start on the middle tab (index 1) ?

Messages is meant to be selected here

a.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Sent" image:[UIImage imageNamed:@"sent.png"] tag:0];
b.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Messages" image:[UIImage imageNamed:@"home.png"] tag:0];
c.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Friends" image:[UIImage imageNamed:@"friend.png"] tag:0];

NSArray *views = @[a,b,c];
[self.tabbo setViewControllers:views animated:YES];
[self.window setRootViewController:self.tabbo];
[self.window makeKeyAndVisible];
[self.tabbo setSelectedIndex:1];

Source: ios

Leave a Reply