Currently, I'm working on universal app (iPhone / iPad) supported on iOS 7 & iOS 8.
Here is my problem regarding size classes :
My navigation bar is defined into a XiB file (NavBarView.xib)
Inside this file, I have a UIButton that I want to display only on iPhone mode, and a UISearchBar only for iPad mode.
To handle that whitout any line code, I used the new feature "Use size classes" available for views since iOS 8. I defined "size classes" for these two elements inside my XiB file.
UISearch for Ipad : Installed for all layouts except Compact Width / Any Height (wC hAny)
UIButton fo Iphone : Not installed for all layouts but with Compact Width / Any Height (wC hAny)
This mechanism works pretty fine on iOS 8 for iphone and ipad, but not on iOS 7. However, if I apply these size classes direclty into views contained into the storyboard, it works for iOS 7.
Could anyone explain me why my size classes are not working when they are defined into XiB files on iOS 7 ?
Best Regards and many thanks,
Lorenzo.
Barely anything to do with size classes is supported under iOS 7. Some good answers here: How can Xcode 6 adaptive UIs be backwards-compatible with iOS 7 and iOS 6?
Adding as an answer since saadnib's comment on the original question helped me a lot.
Size classes on XIB files not being backwards compatible is a bug that has been fixed on xCode 6.1.1. Strangely it's not on the patch notes but I can confirm I'm using a single xib to provide 2 different layouts for a cell on iPad and iPhone. This only started working once I updated from 6.0.1 to 6.1.1.
Limitations on backwards compatibility for classes on storyboards still apply, but they can be worked around.
Figured another option. Size classes will not work, if you add xibs view as subview to UIApplication.shared.keyWindow.
View must be in UIViewController view hierarchy to support size classes.
Thanks to #IvanKvyatkovskiy
Related
Current xib's showing layout issues while switching between devices. I need single xibs which support all ios devices instead of using storyboard.
If you are using xcode 7.3 and above you can vary the constraints based on size class
https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/Size-ClassSpecificLayout.html
for xcode 8 there are some updation but underlying concept is size class , please check this
http://www.appcoda.com/auto-layout-guide/
https://makeapppie.com/2016/09/05/an-introduction-to-size-classes-for-xcode-8/
I developing an iPad application to support landscape only. I have chosen the size classes with Regular Width and Regular Height size. Whenever placing UIView or UI elements and run in the device, It works fine in the IOS 8 but it wont display in the IOS 7. seems looks like size class compatabile issue. Can anyone share your thoughts about how to resolve these UIview to display even in the IOS 7.
Thanks In Advance!!
iOS 7 Does not support size classes. I had this issue and I resolved it by forcing iOS 8 compatibility.
Unfortunately I think your best bet (which is kind of terrible) would be to branch your code and make two separate storyboards one for iOS7 and one for iOS8. That being said, given you are only supporting iPad min and iPad normal, you could do two separate storyboards depending on which device it is.
I know neither of these 3 options is ideal but thus is the cost of backwards compatibility.
Summary:
punt on iOS7
develop an iOS7 specific version and an iOS8 version
develop a separate storyboard for iPad mini and iPad Normal
I have to design an application that supports iOS versions from 6.1 to 8.1. In order to support iOS 6.1, i can't create storyboards with size classes. So i have to use only XIBs and use auto layout for the XIBs.
When i run my application in Xcode 6.1, it looks like all the layouts are perfectly fine. But when i run the same application in Xcode 5.1.1, all the views are reshuffled starting from iPhone 4 to iPhone 5.
Now i have to design my XIBs in such a way that the views are layed out properly in all the devices from iPhone 4 to iPhone 6 Plus. Can someone please suggest me a proper way of how i can create the XIBs that supports all the devices?
Apple has really some solid documentation on how to use autolayout and build dynamically sizing screens using constraints. Another solid tutorial to check out is this one from appcoda. Can be a little confusing at first but once you understand constraints making screens that look nice for all screen sizes is actually pretty straightforward
I'm building an iPad application on landscape orientation on xcode 6.
I used size class
(hRegular wRegular)
.. And it looks good on iPad with iOS8 ..But when i ran it on iPad with iOS 7.1 .. The views is just not appearing.
I tried to target even
(hRegual wAny)
but it's the same..
The funny thing that the only size class accepted by iPad on iOS7 is (hAny wAny)
Hope that anyone can help me in this.
============================
Update
here is an example project for what I mean
iPad Project
When deploying an Application With Size Classes on earlier iOS versions; most size classes are backward compatible.
Following are the key points when using Size classes:
The app is built using Xcode version 6 or later
The deployment target of the app is earlier than iOS 8
Size classes are specified in a storyboard or xib
The value of the height component is not compact
For more information on this subject, Check out this Answer.
I'm starting on adding iPhone 6 support for my app.
I don't want to use Size Classes since the app runs on iOS7 as well.
I'm planning on using auto-layout for views positioning but I'm not sure how to handle font sizes.
I want to make some of the fonts bigger on iPhone 6 plus.
How can I do that using Auto-Layout without Size Classes?
You can use size classes and support iOS7, it's an Xcode related feature to help you design the behaviour of your app.
Get the latest version of Xcode, set the deployment target to iOS7 and start designing your ViewController's using size class.