How does auto-layout work to create interfaces in Xcode 6 beta? What are different size classes & how do they work? How to use the "Resizable Unified Storyboard" to create universal iOS app?
I think you are talking about "Size Classes" introduced in XCode6.
A size class is a new technology used by iOS to allow you to custom your app for a given device class, based on its orientation and screen size.
There are presently four size classes.
At any time your device is going to have a horizontal size class and a vertical size class.
You don't need to worry about device size. Whether it is iPhone 4s, 5 or mighty iPhone 6. UI would be handled automatically for you...
For more info read this article.
See this WWDC Video for more clarity..Building Adaptive Apps with UIKit
With that new feature only aspect ratios are defined. Click at the button "blue" area and you will see the description for the aspect:
wAny hRegular -> For all regular height layouts (e.g. iPhones in portrait, and iPads in portrait or landscape)
Related
I am new to iOS development, I have read about size classes, I have a question about setting properties (or just calling methods with some parameter) depending on ViewController's size class. I am developing a simple radio app, for app design I decided to use Collection View in which I want display logo image. Because I develop universal app and I want to place images in 3 columns or rows on both iPhone snd iPad versions, I need 4 Collection Views for iPhone and iPad for portrait and landscape orientations. For example for iPhone's Collection View I set 75x75 image size for cell, for iPad's 200x200. So for one object (radio station) I need to create 2 image sets, because I do not want just to use the biggest iPad's images on iPhone for two reasons: higher CPU usage, scale issues.
So question is which is the best solution to create objects in array for Collection View with appropriate image size depending on Size Class? Is it good solution to use UITraitCollection to determine Size Class in the viewDidLoad method?
You question indicates you need first to take time to learn some stuff on iOS.
Like you I had to start and learn : it is no problem.
have a closer to auto layoutin iOS
www.raywenderlich.com
then see how easy and fun is iOS development (just need to practice to understand how easy it is). Here is a tutorial for collection views:
www.raywenderlich.com
image scaled
in your image asset
place image with name terminated with
nothing, #2x, 3x
-> easy way to scale image : I use sketch.
I'm trying to add four or (more in future) uiimageview in ipad application landscape mode. I want equal spacing between each uiimageview. I used wRegular hRegular format to build the application and used few constraints, but when i try to run the application in simulator i'm getting different result for different iPad devices. How can i achieve having equal spaces between uiimageview irrespective to size of the screen ? Below is the screen shots.
iPad2:
iPad Air :
iPad Retina :
Resizable iPad :
Auto Layout is a system that lets you lay out your app’s user interface by creating a mathematical description of the relationships between the elements. You define these relationships in terms of constraints either on individual elements, or between sets of elements. Using Auto Layout, you can create a dynamic and versatile interface that responds appropriately to changes in screen size, device orientation, and localization.
Try this link to learn about Size classes and Auto layout.
http://www.appcoda.com/introduction-auto-layout/
I want my iPhone 5s app to simply upscale for the iPhone 6. I have no Launch Images in the project, but I do have the interface builder location declared in the plist to get rid of the black bars. How can I get the app to just upscale, right now it shows white space in Storyboard.
Looking at your question it looks like you are using absolute frame values for positioning, by setting frame.size.{width, height} and frame.origin.{x,y}.
You have two options.
set those values programatically. It's not recommended at all but might be easier to setup. Detect what is the screen's size with [[[UIScreen mainScreen] bounds] size] (check for the height property) or detect the device's version (eg Determine device (iPhone, iPod Touch) with iPhone SDK).
a less slippery road is to transform your project an start using AutoLayout. There's a learning curve but it guarantees that your project will be fitting well any screen. Start here: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html
On iOS 8, apps like Weather and Clock rotate on the iPhone 6 Plus but not on the smaller-screened iPhone 5S. I can override supportedInterfaceOrientations but is there a better way to detect the 6 Plus screen other than specific checks like screen bounds or device model?
I looked into size classes, but couldn’t find a way to detect if a device returns UIUserInterfaceSizeClassRegular on Landscape orientation before the device is actually rotated.
I'm supporting iOS 7 too so I've stuck with checking the screen scale > 2 but if you are on iOS 8 you can use the trait collection. The 6+ in landscape is "regular" width while other iPhones are "compact" width.
See the Apple What's New doc for more info
I want to use the new tech of apple, the Size Classes, but i don't understand why when i select the iphone size, my view have a width of 400p while my iphone have a width of 320p.
Anybody have an idéa ?
Thank
You should watch the WWDC video on developing adaptive apps. Basically, an iphone in portrait has Regular height and compact width size class. This has nothing to do with the real pixel dimension, since Apple might introduce a new phone that's 350pt wide, but still has the same size classes, so your code would work.
Watch the WWDC session video, and use size-classes together with auto-layout to make your apps.