Search code examples
objective-cipadorientationuisplitviewcontrolleruitoolbar

Stop UIToolbar from Disappearing in Landscape Orientation - iPad


Not sure why this happens or how to stop it, my UIToolBar on the details viewcontroller is only visible during portrait view. I want it visible at all orientations. How do I do that? Thank you.


Solution

  • I encountered the same problem by just dragging a UIToolBar on to my view and docking it on the top of the window. It showed up in landscape but not portrait. Interface Builder - at least the one embedded in Xcode 4 - doesn't seem to do the right thing with the resize masks.

    While Kshitiz's answer above will work, it has a couple of flaws. As coded, it does not support all four orientations. More importantly, it's not resolution independent.

    A better solution is briefly described in enamrik's comment, so credit should go to him/her. Here are the steps:

    1. Select the tool bar in Interface Builder.
    2. Open the Size inspector.
    3. In the Autosizing box, select the left, right and top "i-beams" on the exterior of the square. This keeps the position of the toolbar fixed relative to the sides of the view when the view is resized.
    4. Inside the Autosizing square, select the horizontal line with arrows on both ends. This causes the size of the toolbar to change in sync with the parent view.