I have a label sitting on the the top of screen in a tab bar controller app. When I align it to the top of the screen in Interface Builder (IB for short) and then run it, the label is about 20 pixels higher in the simulator - cutting off half the label or so. I have only seen this behaviour in tabbed apps. I have played with all the align, view mode settings without success and there is no custom drawing code.
Any ideas on why label is misaligned in simulator?
I have attached screen shots of IB (left - OK) and simulator (right - bad):
Thanks,
Serge
I guess , you are facing problem because of the following reason.
Since Tab area occupies some height from bottom,You have design your view such that top of the label should align with the top of the screen(like label should start by leaving some space (20px something) at the top).
Thanks to PJR above for giving the hints. The trick is to setup the 'simulated metrics' of both tab bar controller and each of its first view controllers.
1) The tab bar controller --> simulated metric.bottom bar should be set to none
2) All view controller --> All simulated metric props set to 'inferred'.
I have provided screen shots for a fresh tabbed project created in Xcode 4.3.1 which show what needs to be done.
Related
So our app is built using XIB interfaces, not story boards. We have XIBs for iPhone and iPad.
Since the iOS7.1 update the, iPhone xibs are now bigger in interface builder and far too tall when deployed on a device.
The height is all wrong, the XIB is far too tall now. For example, backgrounds appear to go way outside the View when set to fill. When deployed on the phone everything is shifted down about the height of the top nav bar.
If I add/remove Top/Bottom Bars for the View in Interface Builder things shift around but not in a way that makes sense. My app has a nav bar, if I tell the interface builder it has a nav bar then the height of the xib grows a further 80 or so pixels. If I tell the interface builder it has no nav bar, everything shifts up properly but the height of the View is still so tall that backgrounds and stuff near the bottom go off screen.
So for the very vague issue but we are pulling hair over this.
UPDATE
- It seems Opaque Navigation Bar fixes half the problem. We had every interface set with a Translucent Nav Bar. Those do not appear to take up space in IOS7.1 but they did in IOS7.0.
The problem now is still height. It still seems internally the height is broken or starts from a new origin.
In view did load, on a view with a opaque nav bar, on iPod Touch:
self.view.frame.origin.y is showing 0
self.view.frame.size.height is showing 256
Nav bar origin.y = 20
Nav bar size.height = 32
This totals 308, missing 12 pixels.
Create auto layout constraints in IB or programmatically that align the top of the main view in each XIB file to the "top layout guide" and bottom of the views to the "bottom layout guide." This solved a very similar problem when moving from iOS 6 to iOS 7 in several of my apps.
I' m developing an application for both Retina 3.5 and Retina 4 screens (iPhone family). And I encountered with the next problem. I create a view in .xib file and set size to Retina 3.5 full screen.At the very bottom of the screen I placed a view with UILabel. You can see the view on the screen:
As you can see the view is at the very bottom. But when I run the application either on device or the simulator view with label on some reason doesn't fit the screen:
So the question - what can be the problem? How can I fix this? Why IB view sizes is not correct?
You've set your NIB to not have a status bar, but your app does have one. This means your NIB is sized at 480 pts high (on a 3.5" screen), when it should in fact be 460 (due to the status bar). This pushes your view down by the corresponding height (20 pts, which you can see at your cut-off label at the bottom).
There are a number of fixes for this. You could just tell your NIB it has a status bar, but a better option would be to set your view to resize dynamically according to its bounds. Exactly how you do this will depend on whether you're using auto-layout or not, but you'll want to check 'autoresize subviews' and make sure your view elements stay locked where you want them to.
I have a view with a tab bar and a navigation bar. I have a few buttons and textfields in the view. I have some empty space left at the bottom of my view.
While testing on 3.5 inch screen the empty space is occupied by the tab bar. But, on a 4 inch screen I can see the space left clearly. I tried auto resizing every way but it's not working.
Should I go for creating a separate view for the 4 inch screen?
While working with tab bar you dont have to bother for leaving space for tab bar, it'll make it's space by resizing (not cropping) the height of your view. In result the screen size will minimize.
But in this case view's AutoResizingProperty Must be like:
[yourView setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
Or if you are dealing with XIB then it should look like:
With these setting your view will resize itself on bot size of windows.
Notice the Nib on the left displays a layout with 2 UILabels, 1 UITextView and 2 buttons. The Y coordinate of the buttons changes at runtime. What is causing this and how do I fix it?
Update #1 - Problem goes away when I shift to a iPhone Retina 4-Inch display.
Update #2 SOLVED - Problem goes away when by unchecking 'Autolayout' in the xib properties.
It looks like you're using iOS 6 and a storyboard with the 4-inch "tall" iPhone screen form factor simulated. Assuming you are using Auto Layout, you probably have a constraint added to one or both of the buttons that pins them to the bottom of their superview. When you then run your app on the 3.5" screen iPhone simulator, the buttons appear to "move up" as their superview has gotten shorter than on your storyboard.
Find the button with the icon pictured below while editing your storyboard, and click it to toggle the simulated screen size between the 3.5-inch and 4-inch form factors. You should see your buttons re-layout based on their constraints.
To set your buttons' spacing relative to the top instead of bottom of their superview, select both buttons and from the menu bar choose the Editor menu > Pin > Top Space to Superview. (Or use the Pin button pictured below directly from the storyboard.)
There's a good introductory tutorial to Auto Layout here, if you haven't learned about it yet.
My view doesn't stretch to fit the current orientation!
I am creating a tab bar application. I replicated the sample one that you create when you "create a new tab bar application". Everything works except when I change the orientation of the iPad it rotates the view, the tab bar stretches out on the bottom, but the view doesn't resize. Basically if you start in landscape then rotate to portrait, it rotates but the view is still landscape shape even though it rotates.
My tab bar has two tabs (just like the sample application) and so I compared mine against the sample which works property by property. One difference is I noticed my FirstView in IB under the resizing area doesn't show the resize arrows left/right up/down. In other words it isn't marked to auto fill its container. The sample's FirstView and SecondView DO have these arrows. But I can't turn them on!
I even tried creating a fresh new view but I still can't press these arrows on. what am I doing wrong here?'
Thanks a lot.
The solution is this:
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Do this in viewDidLoad. There must be a bug in IB.
Another answer is turning off any simulated tabbars, nav bars, or status bars on the view in Interface Builder. Go into the autosizing area and turn on the auto grow arrows. Then turn back on the simulated user elements.