Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if tabBar is visible on iOS app

I am working on an iOS App that have an UITabBarController for show a TabBar. In some where, I present a modalView full screen that hides the tabBar.

I want to detect when my tabBar is visible for the user. There is any way to check automatically when de tabBar is visible or not?

I tried that:

But it really don't work because the tabBar is not really hidden.

if ([[[appdelegate tabBarController] tabBar] isHidden])
{
    NSLog(@"tabBar IS HIDDEN");
}
else
{
    NSLog(@"tabBar IS VISIBLE");
}

I write this code in a BaseViewController which is super class of my modal view and the other views of my project.

Thanks.

like image 292
ValentiGoClimb Avatar asked Aug 13 '13 10:08

ValentiGoClimb


2 Answers

Checking this [[[self tabBarController] tabBar] isHidden] is fine but in one case it will fail. If you do not have tab bar in that view (at all) then [self tabBarController] returns nil so calling isHidden will return NO which is the truth but you have to detect that situation that it is other case. It is not hidden but it doesn't exits so, except that checking you should add [self tabBarController] != nil. So basically:

if([self tabBarController] && ![[[self tabBarController] tabBar] isHidden]){
    //is visible
} else {
    //is not visible or do not exists so is not visible
}
like image 178
Julian Avatar answered Nov 05 '22 02:11

Julian


You can try this

if ([[[self tabBarController] tabBar] isHidden]){

    NSLog(@"tabBar IS HIDDEN");
}
else
{
    NSLog(@"tabBar IS VISIBLE");
}
like image 41
Toseef Khilji Avatar answered Nov 05 '22 02:11

Toseef Khilji