iOS Question inline OBJC

narek adonts

Well-Known Member
Licensed User
Longtime User
I am trying to hide the TabBar with this code but it doesnt hide it.
could someone advise please.

B4X:
#If OBJC


- (void) hideTabBar:(UITabBarController *) tabbarcontroller
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    float fHeight = screenRect.size.height;
    if(  UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
    {
        fHeight = screenRect.size.width;
    }

    for(UIView *view in tabbarcontroller.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            [view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
        }
        else
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
            view.backgroundColor = [UIColor blackColor];
        }
    }
    [UIView commitAnimations];
}
#End if

Private Sub HideT(tskbr As TabBarController)
Dim nm As NativeObject=app

nm.RunMethod("hideTabBar:",Array(tskbr))
End Sub


when I am trying this method the app crush.

Narek
 

narek adonts

Well-Known Member
Licensed User
Longtime User
it says method not found.
what should I declare as Native Object?

B4X:
#If OBJC


-(void)MakeTabBarHidden:(UITabBarController*)tabBarController :(BOOL)hide
{
    // Custom code to hide TabBar
    if ( [tabBarController.view.subviews count] < 2 ) {
        return;
    }

    UIView *contentView;

    if ( [[tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] ) {
        contentView = [tabBarController.view.subviews objectAtIndex:1];
    } else {
        contentView = [tabBarController.view.subviews objectAtIndex:0];
    }

    if (hide) {
        contentView.frame = tabBarController.view.bounds;      
    }
    else {
        contentView.frame = CGRectMake(tabBarController.view.bounds.origin.x,
             tabBarController.view.bounds.origin.y,
             tabBarController.view.bounds.size.width,
             tabBarController.view.bounds.size.height - tabBarController.tabBar.frame.size.height);
    }

    tabBarController.tabBar.hidden = hide;
}
#End if


Private Sub Hide(tb as TabBarController)
dim no as NativeObject=Me
no.RunMethod("MakeTabBarHidden:",Array(tb,True))

End Sub

Narek
 
Upvote 0
Top