iOS can we create storyboard to landscape? - ios

I am working on iPad project and I need to create a new storyboard or a new view controller for landscape mode so when the user change the device orientation the view controller change.
Can someone tell me if it is possible and if yes how?
if no, what we can do in this situation.
Thank you,

Check Attribute Inspector in IB, there you can set Orientation under 'Simulated Metrics'.

Of course, using size classes and constraints is a better way of going around this - and you can also use the preview that Xcode gives you:
Preview -> Main.storyboard (Preview)
which allows you to set a layout while seeing your results on different screen sizes and orientations automatically. (with assistant editor).
Hope this helps!

Related

How to add support for Landscape mode in existing app

I have implemented an iOS application for both iPhone & iPad, supports only in Portrait mode with OS iOS 7 & above. Now I need to add support for Landscape as well, and I do not have much knowledge on Auto layout and Size Class. Do I need to create separate xib's for Landscape mode? Please share your best suggestions and thoughts.
Please have a look into attached screenshot for how to use SizeClass for design view in Portrait and Landscape Mode.
Have a look into this image for more clarification.
Follow the steps below to add support for navigation
1) In project navigator tab, select your project
2)then select general tab and in Deployment info select checkboxes for device orientation (landscape left and landscape right.)
If you dnt wanna use size classes you can go with Autolayout.
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html

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

Why are all my view controllers square shaped?

I'm trying to get it to be an iphone project, but when I drag any view controller into the storyboard, it's just a weird almost-square, neither ipad nor iphone. What am I doing wrong here? Newest version of XCode.
This is a new feature called "size classes". You can use it to create a universal storyboard for iPhone and iPad at once.
But I don`t really like it so here is how to turn off: In storyboard, open utility inspector (right), then go to file inspector (left) and now disable "Use Size Classes". Then you will get the standard storyboard.
You're not doing anything wrong. The default is to design with UI constraints so that the actual output size doesn't matter.
What you can do is set the size you want to preview your controller at in the options in the right hand pane. E.g.

Icons in tabbar are not displayed correctly

I have an issue with iPad application. I'm porting the iPhone app to iPad. In iPhone, all is working in order but when convert to iPad (Universal app), the tabbar controller looks like this
(vertical lines) Do you guys have any ideas why?
Thanks for any comments or guides.
This can not be in default TabBar. I am sure you are using custom tabbar and its layout are not managing properly in iPad.
So make some adjustment in your custom tabbar and then use it.
Hope it helps you.
Try to check autosizing mask (or autolayout) if you use them.
Then try to check if you change its frame (it could disable autosizing).
It also seems you want to draw these separators manually but tab bar appearance depends on iOS version. At general I advice you to use custom images to a whole tab bar, not its items.

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