No Swipe Back when hiding Navigation Bar in UINavigationController

前端 未结 18 709
生来不讨喜
生来不讨喜 2020-12-04 06:34

I love the swipe pack thats inherited from embedding your views in a UINavigationController. Unfortunately i cannot seem to find a way to hide the Naviga

18条回答
  •  误落风尘
    2020-12-04 07:06

    There is a really simple solution that I tried and works perfectly, this is in Xamarin.iOS but can be applied to native too:

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            this.NavigationController.SetNavigationBarHidden(true, true);
        }
    
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);
            this.NavigationController.SetNavigationBarHidden(false, false);
            this.NavigationController.NavigationBar.Hidden = true;
        }
    
        public override void ViewWillDisappear(bool animated)
        {
            base.ViewWillDisappear(animated);
            this.NavigationController.SetNavigationBarHidden(true, false);
        }
    

提交回复
热议问题