I built an app in interface builder. I use a UINavigationController. Everything is in landscape. When I run the app, the height of the UINavigationBar is CORRECT (32px).
it looks like this (Simulator):
but when I look into interface builder, the UINavigationbar height is 44 px, which is WRONG.
It looks like this (interface builder):
This makes it really hard to edit the UI in interface Builder. When I want to edit the position of any other UI Element, I always have to subtract 12 px for the y-position...
Question: I want my interface Builder to display the navigation Bar correct... with height of 32px. How can I do this???
Related
I have a problem that I can't understand resizing views. My deployment target is iOS 5.0, so I have disabled auto layout in the interface builder to make it compatible with iOS 5.0. The view does not resize automatically. Following is an example:
Interface Builder Snapshot:
4-inch screen:
3.5-inch screen (has problem):
As you can see, the button at the bottom of the view goes out of the screen. The background image also does not resize automatically. I can not understand how I can solve this problem. Can anyone help me?
Welcome to the pre-autolayout world! You must set the autoresizing "springs and struts" so that the stuff at the bottom is attached to the bottom of the superview and not the top. So, struts to the bottom, springs to the top. That way, as the superview gets larger and smaller, the stuff at the bottom moves with the bottom.
You could alternatively reposition the stuff in code, but there's no need in this situation.
Here's the section on autoresizing from my book:
http://www.apeth.com/iOSBook/ch14.html#_autoresizing
The part about the superview and the background image not being resized is a different matter. Is this the view of a UIViewController? If so, then if you are putting the UIViewController into the view controller parent-child hierarchy correctly, it will be resized by its parent. But you have not shown any code, so there's no telling what this view may be or how it is supposed to get into the interface.
Somehow the Segmented Control does not get the proper height when the iPhone is in Landscape.
It is already bad enough when rotating the simulator that the toolbar at the bottom doesn't get thinner height, but when navigating back to the previous screen and then in again, the toolbar does get the propper height, but the segmented control extends above it, and even looks much bigger.
Is the is bug in the simulator or am i doing something wrong?
After digging around another day, I found where it all went wrong!
When dealing with UINavigationControllers, DO NOT drag in a UIToolbar at all! UINavigationController comes with two bars, a top-bar for the Navigation Controller and a bottom-bar for the ToolBar - that latter one is hidden by default.
In any newly added ViewControllers, there will be a toolbar that can be populated from the IB. However, if it is not a UIBarButton, there are some issues. To use a stepper, on/off-switch or a segmented control, drag it first to the Navigation bar, and then in the left column navigator of IB, drag it to the toolbar.
This solved all the problems mentioned before
I have an XIB file that looks like this:
As you can see I have a UIImageView at the bottom of the view, note its all contained within the view.
However, when I run the code which places a UIImage in the view, I get this:
Here is the image I am trying to display:
Image
Why does it go off the bottom of the screen? I've seen similar behaviour in some of my other projects, whats going on?
Thanks,
Jack
In IB, for the top-level view, for the Simulated User Interface Elements, set the Top Bar to be one of the Navigation Bar options. Understand, you will!
hi jack you also do that change view size from interface builder like 320 &460
Has anyone noticed that on the iPhone when the device goes to landscape orientation the top navigation bar gets redrawned smaller?
And that the Interface Builder Simulated User Interface Elements doesn't seem to know this and keeps the same navigation bar height in both portrait and landscape modes. This is annoying as the final position of the UI elements gets different in the IB and when running.
Is it possible to add a "custom" Simulated User Interface Element? (like a Landscape Navigation Bar exactly like the original but thinner)
I think that is because you haven' t set the stretching property accordingly for the navigation bar. Think it is the third or fourth tab in the property inspector. By default their vertical height stays same .. you need to change that height property.
I have a simple view-based app from that template. It has nothing else in there, only one UIButton.
When the device rotates, I want that button to be re-layoutet in such a way that it fits the width of the screen automatically. It has a margin of 20 points left and right, which should always remain the same.
I am not sure what template you are referring to. But if you are adding the UIButton in Interface Builder, take a look at the inspector. What you would need to do is to make sure your UIButton autosizing struts and springs are properly set. There is a preview button that will show you how the button will be autosized if the view changes.