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

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"

Related

Any customized UI in Master viewcontroller in UISplitViewController is lost in landscape orientation

As an example, take the Master-Detail Application template project from Xcode, replace the Master UITableViewController with a regular UIViewController and put a label in the center. See images below. In portrait orientation the label appears as expected, but in landscape it is gone. This is not a matter of bad constraints.
If I change the UISplitViewControllerDisplayMode to PrimaryOverlay the label does appear after swiping in landscape.
I first experienced this problem when setting a custom tableview header on the default UITableViewController that is in the template project, so it is not only a problem when using a UIViewController.
Has anyone else experienced this and know a solution?

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.

Rotation in iPad app

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?

control-drag from view controller in ipad storyboard to toolbar not auto-scrolling storyboard

I just saw a video demo of control-dragging from the view controller icon for an ipad storyboard at the bottom of a view controller to the toolbar within that view controller. While the view controller icon and the toolbar are not on the screen at the same time, the dragging actually scrolls the storyboard enabling the connection between the two.
However, in my ipad storyboard I am unable to make that auto-scrolling happen and thus unable to complete the control-drag.
Is there a way to make the storyboard scrolling happen while control dragging? I thought of temporarily moving the toolbar to the bottom of the screen to make the connection and then moving it back. But the storyboard won't auto-scroll to let me do that either. I'm using a 13" macbook pro. There appears to be no zoom setting that will have both on the screen at the same time.
Alternately, can someone tell me if there is an alternate way to accomplish that? Which part of the code would I control-drag to?
Thanks.
according to this, one can accomplish the same by control-dragging to the icon of the corresponding element (in my case the toolbar) in "document outline pane" which sits between the project navigator and the (storyboard) canvas.
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/SecondiOSAppTutorial/GettingStarted/GettingStarted.html
doing so would bypass the inability to autoscroll within the storyboard.

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