2 Replies
      Latest reply on Jan 30, 2019 6:39 AM by Chopyhoo
      Chopyhoo Level 1 Level 1 (0 points)

        Hi!

         

        I was working on iOS app and found out a strange behaviour of UITabBarController. In one particular case after push to UIViewController with hidden tab bar and going back it shortens the size of UITabBar. The tab bar is translucent and not opaque. This thing happens only if we previously presented UIViewController on a UISplitViewController which is embeded as one of the items of the UITabBarController.

        I've made a sample app to show this thing happen. https://github.com/Chopyhoo/UITabBar-test

         

        Open the app. As you can see there is a normal sized tab bar. Go to the Present tab and tap the button in the middle of the screen.

        There will be presented I am presented screen. Tap the close navigation button.

         

        Then go to the Push tab and tap the Push button in the middle of the screen.

        You will see a screen with hidden tab bar. Go back.

        And here it is. The size of the tab bar is shortened.


        P.S. You can see that in the moment of pushing the I am pushed screen the UITabBar layout is behaving wierd


        • Re: UITabBar size shortens after push on iPhone X type of devices
          Claude31 Level 8 Level 8 (5,735 points)

          I tried it, on simulator (XCode 10.1ß3, iPhone XR simulator).

           

          Can you explain precisely what you get ? What "shortened" means exactly ?

           

          What I could get is:

          - Push

          - Go back

          - Present

          - Go back

          - Push

          Then I see the height being reduced just before displaying the detail

          - when returning, height is reduced

           

          Is it what you observe ?

           

          The problem comes from here where you recreate a navController

           

              @IBAction func presentTapped(_ sender: UIButton) {
                  let presentedViewController = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PresentedViewController")
                  let navCont = UINavigationController(rootViewController: presentedViewController)
                  self.navigationController?.present(navCont, animated: true, completion: nil)
              }

           

          I did not dig very deep, but if you replace this IBAction with a direct segue from the "Present" button to the PresentedViewController", you have not the problem anymore (that is what you did with push).

           

          Why did you choose this complex set up and create a new navigation controller ?

           

          In addition, documentation

          https://developer.apple.com/documentation/uikit/uisplitviewcontroller

           

          states that

          Note

          You cannot push a split view controller onto a navigation stack. Although it is possible to install a split view controller as a child in some other container view controllers, doing is not recommended in most cases. Split view controllers are normally installed at the root of your app’s window. For tips and guidance about ways to implement your interface, see iOS Human Interface Guidelines.

           

          Isn't it what you are doing ?

            • Re: UITabBar size shortens after push on iPhone X type of devices
              Chopyhoo Level 1 Level 1 (0 points)

              Hi, Claude31

                   Can you explain precisely what you get ? What "shortened" means exactly ?

                   What I could get is:

                        - Push

                        - Go back

                        - Present

                        - Go back

                        - Push

                   Then I see the height being reduced just before displaying the detail

                        - when returning, height is reduced

                   Is it what you observe ?


              You are absolutely right, the reduced height is a problem which I am pointing to.

              I did not dig very deep, but if you replace this IBAction with a direct segue from the "Present" button to the PresentedViewController", you have not the problem anymore (that is what you did with push).

              That is not right. I've just tried to make a direct segue to PresentedViewController (it wasn't embeded into UINavigationController), dismiss it and after push the UITabBar height is still reducing.

              Why did you choose this complex set up and create a new navigation controller ?

              This bug was first reproduced in a real production project. In this project I present a whole UINavigationController 'cause I need few navigatable screens to be presented. I don't really think that it is a complex set up. Anyway it is required to be embeded.

              In addition, documentation

              https://developer.apple.com/documentation/uikit/uisplitviewcontroller

               

              states that

              Note

              You cannot push a split view controller onto a navigation stack. Although it is possible to install a split view controller as a child in some other container view controllers, doing is not recommended in most cases. Split view controllers are normally installed at the root of your app’s window. For tips and guidance about ways to implement your interface, see iOS Human Interface Guidelines.

               

              Isn't it what you are doing ?


              No, It's not. In a sample project there is a UITabBarController as a root screen, UISplitViewController is one of its tabs (the tab that's presenting).
              So I don't push the UISplitViewController into navigation stack (iOS won't even let me do that) or put inside UIContainerView.

              But there is one interesting thing I found out. If you'll change the Presentation property in IB of PresentedViewController from fullscreen to over fullscreen the bug will dissappear. So what the difference? The doc says:


              Fullscreen
              https://developer.apple.com/documentation/uikit/uimodalpresentationstyle/fullscreen

              The views belonging to the presenting view controller are removed after the presentation completes.

               

              Over fullscreen
              https://developer.apple.com/documentation/uikit/uimodalpresentationstyle/overfullscreen
              The views beneath the presented content are not removed from the view hierarchy when the presentation finishes. So if the presented view controller does not fill the screen with opaque content, the underlying content shows through.

              iOS uses fullscreen as a default presentation property value. I suppose that's in that paticular case the system somehow removes something. I guess it may be something related to safe area as this bug appears only on devices with safe area on bottom and the tabbar height is reduced exacly by a height of a safe area.

              P.S. As this forum doesn't let to upload images I will put them into the github page of sample project.