Rotation in iPad app - ios

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?

Related

Label in tableview header doesn't appear on ipad but on iphone

in my universal app I have an UITableViewController embedded in a UINavigationController. When I add a UIView to the top of the tableView and insert a UILabel which is centered in the container, the label is only visible on iPhone but not on iPad.
I tried creating a new testapp, only consisting of these two controllers, the view and the label. It works on both, iPhone and iPad. So I added two new controllers to my app in the same way and made the navigation controller the initial view controller. Label is visible on iPhone but not on iPad.
For me it seems, that I have changed some global settings in the app; on another view I have similar problems with stackViews, but I first concentrate on this "simple" problem...
Any ideas what might be wrong in my app-settings?
tableViewController embedded in navigationController
Take a UIViewController embedded in a UINavigationController. Add View, Label, and TableView and check it
Ok. Now I know what was the problem. Never have checked, what's going on with those size classes.
During development I changed from any/any to a smaller size, not knowing, that this is not only taking effect on the layout in the storyboard. Everything I added after changing did'nt show on iPad.
Solution: Select storyboard, in "File Inspector", uncheck "Use Size Classes"

What is the difference between "Inferred" and "Freeform" in Xcode Storyboard?

I have a custom view which needs to be displayed on all the iPhone devices(4, 4S, 5, 5S, 6 and 6 Plus). When creating the custom view XIB, I have mentioned it as "Inferred" but it is not resizing for iPhone 6 and iPhone 6 Plus devices. I am not able to figure out the issue. I am confused on what would be actual differences between "Inferred" and "Freeform". Can someone please explain the differences?
Inferred resizes the scene according to its parent scene. For example if you have a scene that is the size of an iPad and then you add a new scene to your storyboard and create a segue to it, it will automatically resize to the same size as the iPad scene (where the segue originates from).
Freeform ignores the above rule and you're able to size it as you see fit, in the utility pane on the right.
Both of these however have nothing to do with how the view is displayed and sized on actual devices. For that you need to use auto layout and constraints. Or springs and struts. Some even do it in code if they need more flexibility.
“Inferred” is the default setting for storyboards and it means the scene will show a navigation bar when it’s inside of a navigation controller, a tab bar when it’s inside of a tab bar controller, and so on. You could override these settings if you wanted to, but keep in mind they are here only to help you design your screens. The Simulated Metrics aren’t used during runtime, they’re just a visual design aid that shows what your screen will end up looking like.
"FreeForm" Usually you use the freeform property when you add the view controller as a child to another view controller programmatically and you really want to have that fixed size.If you push the view controller or you present it as modal view controller (and you use the modal presentation styles) then there is no need to use freeform.Also another use of the freeform property is to preview the actual size of your view controller when is presented as a modal view controller using existent presentation styles.

XCode can't fix landscape orientation layout in storyboard

I have a simple linear chain of UIViewControllers.
The first one has a show segue to a NavigationViewController, then it goes on the same way with all the others.
When I switch from wCompact-hRegular to wRegular-hCompact to fix the landscape layouts the first viewcontroller doesn't allow me to do anything. The tree diagram at the left side of the storyboard screen shows the views but they are not written in black. They are transparent. Even if I select them and put the coordinates or dimensions nothing happens. There are only a button and a label. Others Controllers are all ok, they can be fixed. What is happening to the first one?
With XCode 6 you can add views, that are only visible in the selected size class (f.e. Compact + Compact). When you change to a different size class the views are disabled. To fix this navigate to the attributes inspector and select installed for any class sizes.

Blur top bar to UIView

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!

Toolbar hiding on rotated UISplitView DetailView

I've based my app on Apple's SplitView project type. I have a TableView as the Master, and am using different types of views as the Detail view. To select types of detail view, I'm using the fancy concept of buttons on my DetailView toolbar. When the DetailView is derived from UIViewController, everything is good. When the DetailView derives from UIViewController, but contains a UITableView then I have problems. In portrait view the toolbar is visible. In landscape mode the toolbar is hidden, even though the Tableview is moved down to allow space for it. The UIToolbar and UITableView are both defined in my NIB file which is loaded to create the detail view. Why is my toolbar invisible in landscape?
BTW, is this the best way to choose Detail view types with UISplitView? Bonus question, what if selecting a row in my DetailView tableview should bring up another View, I can't push it like I would with a NaviagtionController, so how do I go back to the detail tableview?
Thanks, Gerry
HI Gerry,
I have faced the same toolbar problem, when trying to rotate the splitView, toolbar will disappear. If you are creating the toolbar in the interface builder, try to set the toolbar properties(size), by selecting the toolbar, then --> Tools -->Size inspector, in the autosizing section, mark the left, right and upper red lines and unmark the bottom red line, then everything will works fine.
-Maria
Bonus question, I would create a UINavigationController in code, set it's rootcontroller to the DetailView tableview (self) and then push the new view on top of it.
When you react to the rotation change are you using the same view or a different one for the detail view? Seems like the new view may not contain an instance of the toolbar? Or the Tableview is covering it up because the landscape view has less vertical room than the portrait view. Are you resetting the height of the tableview to allow space for the toolbar within the 768 height when rotating to landscape?
Just a tip but whenever I run into odd things like this I remove the elements from the NIB file and create them programmatically in code and it usually solves the problem. You get a lot more control over things when you do. Overall as I've gained more experience with programming for iPhone OS I've found that I rarely put much into a NIB file any longer and do almost everything in code now.

Resources