I made a "single view" app with a UIView interface in a .xib file. I added a navigation bar at the top with some buttons on it and all worked fine in iOS 6.
With Xcode 5 my navigation bar is too short and buttons overlapped status bar. I tried to add a "top bar" in the "Simulated Metrics" panel but once I run the app the bar does not appear (even if it appears in the .xib file during editing).
Same problem when I tried a tool bar because I need a 64 pixel (instead 44) high blur bar.
Does a simple solution to this problem exist? Thanks!
Simulated metrics, while editing a storyboard and/or xib are, are there for you to use when stubbing out your design. They will not show up at run time. Think of them as fictional representations or a prototype of what you would like to see in your design without actually having to implement it yet.
IE: You're not sure if you want a UINavigationBar in your design. You can layout your design with the UINavigationBar turned on in the simulated metrics and it'll show you what it looks like, but only in the editor not actual run time, and from there you can make your decision on whether or not to keep it or rearrange your other controls. Something like this is very handy if you create your UINavigationBar programmatically (like I do). If I simulate the UINavigationBar (even though I'll create it programmatically) then I can get a much better idea of where to layout all my other controls that I DO setup in IB.
All that being said, if you layout all your xib's and SB's in the interface builder then the simulated metrics really is worthless to you for the most part because you can obviously just drag and drop the control onto your xib.
Hope this helps!
Related
I am developing an iOS application using Universal Story board and autolayout. The base views of my view controllers are leaving a space at the bottom and are not taking the full height of the screen. What could be the reason behind this?
Go to property area in the storyboard and choose your main view then select all the lines which is available in that area. then it holds the full view of the page.
It looks like your view is taking up the whole screen but is hidden behind a tab bar.
This will happen when you include them inside of a UITabbarController. The reason they reach down underneath the tab bar is because it is translucent (you can see a blurred version of the view through it).
This tutorial from Ray Wenderlich gives a good example and explanation of how to set this up in a storyboard.
https://www.raywenderlich.com/50308/storyboards-tutorial-in-ios-7-part-1
Actually the "Show Toolbar" option for my navigation controller was checked. The space at the bottom was taken by the toolbar.
I've been searching SO and Google for a while now with no luck.
What I need to do, is in certain conditions, display a status bar at the top of my application.
When this bar shows, I need to shrink all the other content down so everything still fits on the screen.
I know I can use CGAffineTransformScale, however, I am not having any luck doing it globally for the entire app.
I'm sure I'm missing something obvious. Guess my lack of experience is showing.
Thanks
EDIT: The 'status' bar I'm referring to is NOT the standard iOS status bar. It is a custom status bar that appears only in certain conditions and sits at the top of the app.
I would check your autolayout settings on the first view you added to the controller - if you have them setup correctly then it should resize automatically.
If you use a UIViewController or any concrete subclass of that, its view should automatically adapt to whether or not the status bar is currently visible.
Now in case you use autoresizing masks, your UI should be fine. Same should apply if you use a UIScrollView.
Alternatively: In Interface Builder, select your view controller and on the attributes inspector turn off Layout: Wants Full Screen. Then, your layout will automatically adjust its size to make room for the navigation bar.
Im working on an app with a viewcontroller buried deep inside a drill down. Im working with autolayout and would like to view my changes without having to go thru the rest of the app processes.
is there a way to view what a scene will look like onscreen without having to run the entire app?
There is a menu option called simulate document. Unfortunately, newer versions of Xcode no longer have this available for iOS apps, OSX only.
If you only want to see the effect of changing between 3.5inch and 4inch phones, or orientation changes, you can change the simulated metrics on the storyboard. This will show you how your ui elements will lay themselves out based on your autolayout settings. Anything you are doing in your code in your view controller won't take effect since you're not actually running anything. This will only show you results based on things you have set in the storyboard.
To do this, select your view controller on the storyboard and open the Attributes Inspector (Cmd+Option+4).
All of the simulated metrics are likely set to Inferred. You can change the size and orientation here.
Using this you can at least find some errors. Say I have a button at the bottom of the view, but I set the constraint to "Top Space To Superview" instead of bottom. When I change the Size Simulated Metric to the 3.5 inch, this button will be off the bottom of the screen.
In my iPad app, the view controller include three button, one navigation bar and one tool bar.
When i rotate my view controller from portrait to landscape mode, three buttons are disorder.
The navigation bar also collapse to tool bar.
How can i do it?
You need to learn about layout. You can lay out subviews of your view in three ways:
Manually
Autoresizing (springs and struts)
Autolayout (constraints)
If this is a new project in Xcode 4.5 or later, you are using autolayout by default. So you need to go back into the nib and edit the constraints that Xcode already gave you, because obviously they are not what you want.
You might want to read the Layout section of my book, which has extensive discussion of how autolayout works and how to edit constraints in the nib: http://www.apeth.com/iOSBook/ch14.html#_layout
Ideally you should keep your content under one xib per view controller, linking your buttons and nav bars by pinning to your layout should rotate properly; however there is one other option for a viewing a different xib when the device is rotated, see the answer below.
Easiest way to support multiple orientations? How do I load a custom NIB when the application is in Landscape?
I have a project where a custom height navigation bar is used across the app so it is 62px instead 44px tall. I am trying to build and layout my views using the storyboard editor (interface builder) although when using the Top Bar attribute set to Navigation Bar under the simulated metrics under the view controller options, this turns to be the default 44px one and not the custom height navbar (64px) I want.
This way all the view work area shows up on a different size and I always need to calculate what is going to exceed or not.
Is there any way that I can use both simulated metrics and a custom height navbar subclass gracefully while keeping the exact height I will have to work on the remaining space?
It is not possible to change the Simulated Metrics to custom values by Xcode.
A possibility is to design the custom navbar and copy it everywhere instead of the navigation, but then it is not simulated any longer.
Or you could make a little hack by going into
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/PrivatePlugIns/IDEInterfaceBuilderCocoaTouchIntegration.ideplugin/Contents/Resources
and open CocoaTouchConstraints.plist
In this file you can set the value of NavigationBar to the desired values. So if you want a Navigation Bar that is 60 high just set Maximum and minimum height to 60:
<key>NavigationBar</key>
<dict>
<key>MaximumSize</key>
<string>{10000, 60}</string>
<key>MinimumSize</key>
<string>{0, 60}</string>
</dict>
After saving you need to restart Xcode and you NavigationBar will have the desired height.
I'm afraid you can't really do that, if you want to have a similar behavior and a correct auto layout and constraints directly in Interface Building add a simple view for your custom navbar class with the correct metrics, (it will work just fine as the navigation bar inherits from UIView) just add the view, set the custom class, and add the constraints for both, the navigation bar and the top objects of your view.