RemoveFromSuperview shows white space

I am using a nested TabbedPage within Xamarin Forms but would like to remove this TabbedPage from iOS as I am re-creating it and placing it at the top of the page. I have a custom renderer and inside the ViewDidLoad method I am using this.TabBar.RemoveFromSuperview();

This removes the TabBar but the space it occupied is still there. Does anyone know how to remove this space?

Answers

  • MarketAllyMarketAlly USMember ✭✭

    @DanielPease.2022 said:
    I am using a nested TabbedPage within Xamarin Forms but would like to remove this TabbedPage from iOS as I am re-creating it and placing it at the top of the page. I have a custom renderer and inside the ViewDidLoad method I am using this.TabBar.RemoveFromSuperview();

    This removes the TabBar but the space it occupied is still there. Does anyone know how to remove this space?

    Did you figure this out?

  • DanielPease.3000DanielPease.3000 USUniversity

    Yep I figured it out. The fix is to remove the Tab Bar then resize the height of it's frame to 0.

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        this.TabBar.RemoveFromSuperview();
        this.TabBar.Frame = new CGRect(this.TabBar.Frame.X, 
        this.TabBar.Frame.Y, this.TabBar.Frame.Width, 0);
    }
    
  • HassanTariqHassanTariq PKMember ✭✭

    If anyone still having problems fixing this issue. I had to use the device.BeginInvokeOnMainThread function for fixing this issue. I also somehow had to use the Task.delay(100) for completely fixing this issue. I don't know why delaying thread fix my issue. Here is my code that I have used. You can first try with only Device.BeginInvokeOnMainThread and then if this does not fix the issue use the delay function.

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Device.BeginInvokeOnMainThread(async () =>
            {
    
                await Task.Delay(100);
                this.TabBar.RemoveFromSuperview();
                this.TabBar.Frame = new CGRect(this.TabBar.Frame.X,
                this.TabBar.Frame.Y, this.TabBar.Frame.Width, 0);
            });
        }
    
Sign In or Register to comment.