iOS hidesBottomBarWhenPushed not working

ios

#1

Hi, i am new on Nativescript and have minimal knowledge about native iOS.

I am trying to hide bottombar of tabbar view on both ios and android.
Currently my approach is like this :

onTabViewLoaded(event: any): void {
    
    let tabBarLayout = this._page.getViewById('messagesTabView')

    if (isIOS) {
        // i try to use this. the tabbar is hidden but leave blank space 
        // tabBarLayout.ios.tabBar.hidden = true

        tabBarLayout.ios.tabBarController.hidesBottomBarWhenPushed = true
    } else if (isAndroid) {
        tabBarLayout.android.getChildAt(0).setVisibility(android.view.View.GONE);
    }
}

Android approach is working. But on iOS i am struggling. i found way to do it using hidesBottomBarWhenPushed. I believe it will work but my implementation is wrong. Please help me how to use this method? thanks. :slight_smile:


#2

tabBarLayout.ios itself is the UITabBarController. So you may try tabBarLayout.ios.hidesBottomBarWhenPushed.


#3

thanks for the reply! but its not working :confused:


#4

@dedetulus I tested it myself already, it worked. FYI, hidesBottomBarWhenPushed hides the TabBar when you open a new page not on the TabView page itself. If you are looking to hide it from the TabView itself, then it is not the right option.


#5

I see… My case is hide the TabBar from TabView so i can design a custom TabBar for my TabView. My another option is using AbsoluteLayout for TabView container then calculate AbsoluteLayout height + (fixed value for TabBar height) and set the TabView height using this value. (overflow).

i’ll try my other method. thanks for your support!


#6

@dedetulus This worked for me to remove the blank space. There is a timeout because native view’s frame was not yet set on loaded event. You may ignore that if you want by listening to bounds change. Timeout was quick hot fix for me.

const tabView = (<TabView>args.object),
        offset = tabView.ios.tabBar.frame.size.height;

    setTimeout(() => {
        tabView.items.forEach((item) => {
            const nativeView = item.view.nativeView,
                frame = nativeView.frame;

            nativeView.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height + offset);
        });
    });
    tabView.ios.tabBar.hidden = true;