I have a general question to iOS 6 and AutoLayout in the Simulator.
My app is targeting iOS 5 and iOS 6 as well. I need to switch-off AutoLayout in StoryBoard otherwise the app is crashing in the iOS 5 simulator (since AutoLayout is supported first with iOS6).
But when I start the iOS 6 simulator all views are rotating and all subviews are resizing accordingly. Using iOS 5 simulator all views doesn't rotate with changing the device orientation.
Would that happen on real devices as well? So, even with switched-off AutoLayout option in Storyboard would all the views rotate with the device orientation with iOS 6 and better on a real device?
Thanks!
Apple changed how autorotation works in iOS 6.
If you create a project in Xcode 4.6, Xcode sets it up to use the iOS 6 autorotation API. The project template allows portrait, landscape-left, and landscape-right orientations (and upside-down portrait in an iPad app). So when you run the app on iOS 6 (device or simulator), the app allows interface rotation.
When you run that project on iOS 5 (on either the simulator or the device), the system ignores the iOS 6 autorotation API and looks for the shouldAutorotateToInterfaceOrientation: method on your view controller. Since Xcode 4.6 didn't create that method (and presumably you didn't add it), the system uses the default implementation, which is only returns YES for portrait orientation. Thus on iOS 5 you don't get any interface rotation.
The simple solution, if you don't want interface rotation, is to go to your target's Summary and turn off the landscape orientations.
You can learn more from several official sources:
The “ Handling View Rotations” section of the UIViewController Class Reference.
The “UIKit” section of the iOS 6.0 Release Notes.
“The Evolution of View Controllers on iOS” video from WWDC 2012.
Like #Patrick Tescher said, you can't use Auto Layout in iOS 5.
You should also consider the fact that only 6% of the users have iOS 5, as of June '13. At the same time, iOS 6 adoption is at 93% (source). This is a very high number. So depending on your situation, perhaps you don't have to make your app iOS 5 compatible in the first place. Spending twice the development time on a feature to make it work for 6% users may not be the best use of one's time. Unless it's a business decision and you get paid in either case :)
If you want to support iOS 5 you should not use auto layout. Auto layout is only supported in iOS 6 and later.
You can technically have two storyboards and load one for iOS 5 and one for iOS 6 but you would be duplicating a lot of work. Best to just hold back on Auto Layout until you can remove iOS 5 support.
Related
I've just got my iPhone 6 plus and noticed that a lot of the Apple apps are using the iPad version when rotating the phone to landscape. It makes sense since the screen is so large.
So my question is. How do I detect this in Xcode to target iPhone 6 plus phones to run the iPad version of my app?
There is nothing to detect. An app should be written so it doesn't really care what device it is on. Everything should be based on size classes and auto layout.
In the examples you mention (in the comments), most likely what you are seeing are UISplitViewControllers which looks similar on the iPhone 6+ as it does on the iPad.
Just write a proper universal app with one set of screens that properly adapt themselves based on the current size class.
I am planning to use different storyboards (one with and another without autolayout) because I need to have my app from 4.3 to 5.0(without autolayout) and 6.0 onwards (with autolayout) but I cannot build it on my device as I'm failed by
Illegal Configuration: Auto Layout on iOS Versions prior to 6.0
I don't think I should disable my storyboard autolayout as I got another storyboard to cater the old devices.
How do I able to manage this?
Note: regarding why I need to support the iOS 4.3 / 5, I cannot make the decision as my business management made that decision. If I support iOS 5 onwards, is there a way to counter for this?
I have to develop an app that should run on all the iPhone devices, whether it is iPhone 4/4S, iPhone 5/5S, or iPhone 6/6+, using Xcode 6.1.1. Will an app developed using Storyboard run on devices prior to iPhone 5?
If not, then what things should I consider so that app will run seamlessly on all the iPhone devices?
Storyboard and ARC will work till iOS 5.
Apple Document:
Storyboard Compatibility
Note: This are Some Nice Tutorials About AutoLayout.
AppCoda,
raywenderlich
Try to adapt with Size classes and auto layout. First I didn't know how autolayout and sizeclasses work, and it was so tough for me. Yeah, now the problem with multiple screen is not a big deal anymore.
Please read apple's docs:
Auto Layout Link
Size Classes Link
Right now I am working on non-arc project for ios3.0. They haven't designed anything by interface builder. Everything coded is both for landscape view and portrait view separately. My Problem is when I try to add the same image for background of another screen, it appears to be cropped. also enabling the auto resize subviews gives me error. When I try to set views for portrait and landscape view, it doesn't work.
one more thing, that project is only developed for iPad. if they want it to be done for iPhones, should i have to start from scratch separately for iPhone because of above mentioned problems ?
please suggest me if the upgraded app will support for 64 bit ipad retina.
Thanx in advance
Make your project universal by changing the setting shown in the image below. Also it is better to drop support for iOS 3 as nobody uses it anymore and support iOS 6 and above. It will give much more options and flexibility regarding frameworks and layouts.
To support 64-bit devices you have to build with iOS 5 or higher as minimum supported iOS version. Best practice is to support the two latest releases (iOS 6 and 7 at this moment) as most iOS users update their devices fast after each os release.
How to make ios app compatible with iphone4 devices (i.e 3.5 inch), which is already built in iphone 5 (4.0 inch screen) without creating different xib?
Use Autolayout to allow your app to correctly resize to the correct screen size.
Raywenderlich.com has a good tutorial to get you started, and the Cocoa Auto Layout Guide is excellent, although it is written primarily for Mac apps.