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.
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.
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.
When updating my old program for iPhone 5's 4 inch screen, I found that the navigation controller keeps to its original 3.5 inch screen size and refuse to stretch to fit the 4 inch screen even when its view controller's view and tableview controller's view are all stretch to fit the 4 inch screen. Because the navigation controller's view is not visible during normal use, people may miss it. Because it refuses to fit the new 4 inch screen, when in landscape mode, the screen go beyond the navigation controller's view width and the right button fall off the boundary and becomes unresponsive. In order to show the situation above, I set the navigation controller's view's background color to semi-transparent red and the table view's background color to semi-transparent blue. as shown in the screen shoots below. The question is, how to fix the problem. the plus button are not responsive when in landscape mode, but in portrait mode, it works fine.
Either your navigation controller’s view or, more likely, the window that contains it, are not getting set up with the correct frame. If you’re creating the window in code, make sure you’re using UIScreen -applicationFrame or -bounds rather than a hardcoded (320, 460) or (320, 480); if you’re using a NIB, check your autoresizing masks and layout settings.
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.
I have a TabBarController, one of the tabs of which contains a sub view which is a navigationController. I am then loading into the navigation controller a view which inherits form UITableViewController.
My problem is thta for some reason the table view starts behing the navigation controller, not the top of the screen but about half way down the navigation bar, hence the top of the first cell in the table view is cut off.
Can anyone suggest how to move the UITableViewController down?
Fix it programmatically:
- (void)viewDidLoad {
UIEdgeInsets inset = UIEdgeInsetsMake(20, 0, 0, 0);
self.tableView.contentInset = inset;
}
This "tucked in behind the Navigation bar" issue is due to iOS 7 using fullscreen layout automatically. See the iOS 7 Transition Guide.
It's a bit devious since it displays as in iOS 6 in the Simulator (layout-wise; ie. not tucked in behind).
Is your navigation bar translucent? Mine was, and setting it to non-translucent fixes it on Iphone iOS 6, iPhone iOS 7, and Simulator 7.0 building with XCode 5. (In my case I set it to translucent for visual appearance.)
You can set the frame of the UITableView to an explicit X,Y position by setting the frame property on the view. Or you can change the same property using interface builder depending on whether you've added the tableview via IB or in code.
eg.
myTable.frame = CGRectMake(0.0, myTable.frame.origin.y + NAV_BAR_HEIGHT, myTable.frame.size.width, myTable.frame.size.height);
This will position the table myTable (which is a pointer to the UITableView) below the navigation bar, you may also need to adjust the height of the table accordingly. The height of the nav bar which I am indicating with a constant is 44.0.
I typically do this type of view adjustment if it has been necessary in the viewWillAppear of the view controller responsible. It's not common that you'll need to make this type of adjustment so it may be something you can fix by changing the way your views are being setup.
Without more details of how your view is setup it's hard to be more specific.