fail to set view landscape in storyboard - ios

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

Related

How To Fit UITableView in the screen with AutoLayout

I am trying to fill the screen with a TableView. I've tried pinning 4 edges but it broke when I view it in different devices (iPad Pro, iPhone SE, landscape and portrait orientation). The TableView is messed up for some reasons. It shouldn't be this hard to fill that in. Did I messed up some settings in my Xcode?
If you ran the application on a real device you'll find it as you expect it to be.
And if you opened another file then came back to storyboard you'll find the preview as expected too, I think it's a bug in the UI Builder.
Note: I'm using Xcode Version 8.3.2.

Same Storyboard for different screen Sizes without Auto Layout

I've been using different storyboard for different screen sizes.
Now, I'm updating an old app with only one Storyboard for iPhones and it looks the same appearance as iPhone 5 in different iPhone simulators, without using auto layout. Works well on iPhone6 and 6 plus Simulator.
Can I trust this behaviour or is any simulator bug? Is it due to any Properties project config ?
You must use auto-layout otherwise it will not work 100%. If you enable auto resize subviews option in storyboard view then it might work upto some extent.
I got it... Just not setting any launch screen image for the devices without defined storyboard

Appropriate way to manage different views for portrait and landscape?

I'm developing an app targeting iOS 7 and above. I'm using storyboard and autolayout, and I have to show different layouts of each storyboard scene depending on the device orientation, I mean, for example: in portrait I may have a button at a certain place that has to be shown in another place in landscape, or I may have controls in portrait that should disappear in landscape and have to rearrange the rest of controls.
My question is: when there are a lot of differences between portrait and landscape, should it be better to manage all this changes by programmatically updating constraints, or should it be better to create different nib files and load the corresponding according to the orientation?
use size classes their will be no problem in giving support to ios7 . I have tested their were no major problems in ios7 while using size classes.

XCode Storyboard - View appearing in Landscape?

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

Xcode storyboard: Why does the iPad storyboard show iPhone sized views?

I have a universal app that uses storyboards. There is an iPhone storyboard and an iPad storyboard. However, in interface builder, the viewcontrollers for the iPad storyboard are still sized for the iPhone. How do I get the iPad storyboard to show iPad sized view controllers?
I realize that the view controller display in interface builder is design-time-only eye-candy, but having iPhone sized VCs makes it really hard to lay out the UI correctly.
After some digging through the storyboard source code, it turns out that the iPad storyboard was copied from the iPhone storyboard. So, the question really became how do I convert an iPhone storyboard into an iPad storyboard?
The answer is surprisingly simple. I ran across this SO answer -- to convert an iPhone storyboard to an iPad storyboard, do the following:
From Xcode, right-click on the storyboard and choose Open As ->
Source code
Search for targetRuntime="iOS.CocoaTouch"and change it to targetRuntime="iOS.CocoaTouch.iPad"
Right-click on the storyboard again and choose Open As -> iOS Storyboard
The storyboard will now show all views in the correct size.
When you first create a storyboard you select a Device Family (iPhone or iPad) that the storyboard is targeted for. I don't know of a way to change the device family once the storyboard has already been created.
However, to solve your problem I recommend the following:
Create a new storyboard by going to: New -> File -> User Interface -> Storyboard (Be sure to select Device Family = iPad when choosing the options.)
Go to your old storyboard, select and copy everything by pressing Command-A, Command-C. Then go to your and paste everything by pressing Command-V. Your view controllers will now be iPad-sized.
You can then delete the old storyboard and rename your new storyboard to whatever the old name was.
This answer is not a solution, but will help to get one of the reasons why such things happen.
The issue occurs when you try to disable:
"Use Auto Layout"
When you uncheck it, the popup window appears. There is select:
"Keep size class data for: iPhone", by default is selected iPhone (no matter which iPad or iPhone project you created).
If you will not mention on it, your storyboard will be auto converted to iPhone sizes.
Do not forget to choose right device.
I used the suggested answer to convert an iPhone storyboard to an iPad storyboard and it worked great for most of my views. However, I realized that one of the views was still iPhone storyboard sized. The reason was because I had locked All Properties of one background image (because I did not want to accidentally move it). Removing the lock turned the view back into iPad sized. This might help someone stuck on this.
Make sure you set the right Storyboard in Target > General. This kinda stuff makes me headache for 3 hours before i realise i set the same storyboard for iPhone as my iPad storyboard.
In my universal app, I was using SpriteKit for the main viewcontroller. The SKScene.scaleMode was set to aspectFill. When run in the iPad simulator, the app started up iPhone mode. Solution was to set scaleMode = .resizeFill.
For me i have found it more easy by changing the view controller presentation to Full Screen rather than Automatic, I use Xcode 12.1

Resources