Alright so here is the deal. I have 5 tabs, 3 of them are just links. So when the user clicks on them, it actually brings them to a website using this:
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{...}
So the tab bar item pretty much works as a button.
The links work just fine but the problem is that I don't want a view loaded on the click. So initially I added some [UIViewController alloc]
for self.viewController
(in the tab bar controller). Those view controllers are blank but they allow me to add the icon like so:
UIViewController *vc = [UIViewController alloc];
[vc1.tabBarItem setImage:[[UIImage imageNamed:@"tab-fb"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
vc1.title=@"Facebook";
All of this works fine, but when the user clicks on it, there is a blank black view. I understand this is normal, but how do I get rid of that? I want the user to be able to stay on the current view, but be led to the link.
I tried doing something like this:
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
selectedIndex=[[tabBar items] indexOfObject:item];
if(selectedIndex == 1){
[self setSelectedIndex:0]; //RIGHT HERE
//...code to go to link...
}
}
but for some reason, the program does not respond to [self setSelectedIndex:0];
Any tips?