XCode Storyboard - View appearing in Landscape? - ios

Building an application which started as fairly simple, but now got pretty complicated. I am facing a strange problem. I am now using only storyboards to define all of my views. The problem I am facing is, some view-controllers in storyboard are appearing in Landscape mode and others in Portrait mode.
I know it won't make a difference in final application, but it is making it hard for me to design and visualize things. Has someone else faced this problem?

Click on the view in storyboards , click on the attributes inspector (third from the top left) in simulated metrics change the orientation to portrait

Related

UISplitViewController - Use as slideout-style menu

I'm struggling a bit with the new UISplitViewController in iOS 8.
I want to achieve a slideout-style menu on iPhone (landscape and portrait) as well as on iPad in portrait orientation and a persistent sidebar on iPad in landscape orientation.
I got a UITableViewController as the master and a UINavigationController with a couple of UIViewControllers as the detail in my SplitViewController.
Is it possible to to get something like this with the new UISplitViewController in iOS 8?
First it would be enough the get the iphone sliding thing to run :D
Thank you :)
The UISplitViewController will do just that. Sliding menus and everything.
It works like a dream if you use it exactly by the book. And this requires setup of some UINavigationControllers as part of the magic.
Tutorial is highly recommended for the first time. It's easy to get it messed up quickly otherwise. :)
http://nshipster.com/uisplitviewcontroller/
By default, the UISplitViewController in iOS8 will only act as a slideout-style menu on the iPad (in both portrait and landscape mode) and iPhone 6+ (in landscape mode only).
As to whether or not it is possible to get the slideout-style menu working on all iphones via the splitViewController, I don't actually know (I'm still new to iOS development). I suspect that it entails modifying how the splitViewController treats different size classes. If there isn't an easy way to change the splitViewController's behavior, perhaps you could subclass the splitViewController and override the functionality that you do not like.
I have not tried this before, nor do I actually know how the controller determines how it is displayed in different size classes. However, if I were trying to accomplish what you are, then this is what I would be looking up.

fail to set view landscape in storyboard

I am trying to develop a landscape app on iOS, at the first step I want to set the view to landscape so I can design the view much easily.
But after I chose the orientation->landscape nothing happened in storyboard, I checked some tutorial video, all their storyboard view change to landscape right after set it.
Anyone know what causes the failure of setting landscape?
My Xcode is quite weird for several problems, I tried to reinstalled it but problems still existed.
I suppose, you are using size classes in xcode 6. If so then change your size classes to Regular Compact in storyboard. Or else turn off size classes and Autolayout.
Click on file inspector(leftmost button in the tab) and check whether autolayout and size classes are turned on.
Did you try changing the size from default "inferred" to lets say "ipad air"
and then try switching between potrait and landscape from simulated matrix .
Try to turn off the AutoLayout

portrait layout wont scroll in landscape orientation

Im quite new to XCode and Interface Builder, so forgive me if the solution is obvious.
I have designed a nice portrait IPhone view in interface builder (XCode 5) and have set the constraints on each of the elements (labels, text views, switches, buttons etc) so that they are positioned correctly in either 3.5 or 4 inch portait mode in the simulator.
However, when I rotate the simulator to landscape it breaks the design with elements overlaying each other and other elements disappearing (being clipped from the view) - and I expected this.
My idea of a solution is to put all of the UI elements inside a UIScrollView and set constraints on the scroll view so that it fills the screen in either portait of landscape mode.
After doing this, the portrait view is as before in the simulator, but in landscape view nothing scrolls, and none of my UI elements respect their constraints (stretch horizontally etc). Im still losing UI at the bottom and I cant scroll it into view.
I assumed that putting everything into the scroll view would simply 'fix' this issue, but the scroll view seems to do absolutely nothing at all. I have fiddled with various settings in interface builder but nothing fixes this.
There seem to be lots of long-winded solutions to this type of scenario based on code, but surely something this simple and common should just 'work'
What am I missing, or what have I done wrong, or does simple scrolling really have to be extensively coded in order to work ???
Putting all of your elements inside a scroll view won't really solve anything. Those elements would still need constraints to know how to position themselves in the scroll view. You need to be careful as well, as this solution sounds like something that goes against apples human interface guidelines. I'd advise against ignoring those, as Apple are known to reject apps that do this.
I'd say your problem is your constraints simply aren't setup correctly if elements are cover other elements and moving into the wrong places when rotated.
Annoyingly the WWDC videos section of the developer site is still down, but when it's back up, have a watch of the video of autolayout in Xcode 5, it will help explain what's going on.
If you want elements to completely change position when rotated however, you're likely to need more than just constraints, and would need to throw in some code to handle the transition between portrait and landscape. So it really depends on what the view is supposed to do when you rotate the device
OK, Ive figured it out. It IS a bug in either XCode 5 or IOS 7
I created 2 simple iphone UI's in interface builder - one in Xcode 4.6.3 targeting IOS 6.1 and the other in XCode 5 Beta 4 targeting IOS 7 beta 4.
The first app ran entirely as I had assumed, with the scroll view scrolling in landscape mode. The second app had no scrolling at all in the scroll view - so obviously a bug.

Xcode View Controller - Horizontal orientation issue

I have got two view controllers on a Storyboard in Xcode. If I Build and run the application with the initial View controller set as the startup item (The app only allows horizontal orientation) then the application in the Simulator is displayed correctly with all the images in the correct place in Horizontal orientation.
However if I add another View controller to the Storyboard (setting this as the startup item). The simulator is run and displayed horizontally however the graphics are being displayed as if the screen is in vertical orientation.
The plist looks correct and also I have tried setting up the simulated metrics to Landscape and Full Screen. However this does not seem to have worked. The display looks correct within Xcode. It is just when I come to run it on the simulator.
I have searched across Google and have come across articles on Rotating iPads and Orientations.
Can anyone help with my issue? Do I need to add any extra code to get my new view controller to be recognised in the horizontal orientation? or is this a bug with simluator?
Thanks
I have found out the answer to the question myself and I thought I would share.
All I needed to do was select the ViewController Class in the Utilities Screen.
I assume by doing this it can invoke the shouldAutorotateToInterfaceOrientation method and also know which way around the screen should be.

Landscape orientation for iPad?

Frustrated by how simple this should be...
I'm trying to add landscape support to an existing iPad app of mine. Do I actually have to create a completely new view controller for landscape mode? (surely not as that is a complete pain!)? Or can I use the existing view controllers and design for landscape and portrait? The simulated metrics thing doesn't work because whenever I make changes in a view controller in landscape mode and switch back to portrait it messes everything up! I know how to switch the view to landscape programmatically, this is (at least i think) an 'interface builder' sort of issue.
Why is this so difficult to do/hard to find!? Might be worth mentioning I'm using Xcode 4.2 with storyboards rather than separate xibs. Surely I don't have to use a separate view and segues because I really can't be bothered wasting my time with that.
Any help would be nice! Thanks
Watch for -willRotateToInterfaceOrientation:duration: and change the frame of your interface elements when the rotation changes.

Resources