equal spacing between uiimageview using size class - xcode

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/

Related

UITextField in UIToolBar not adhereing to Size Classes

I have a UITextfield in a UIToolbar and it doesn't seem to want to stretch from end to end like it does on an iphone. So this is what I have for the w:any h:any size class
That works just fine on iphone devices. But when I align it on the w:regular h:regular size class for ipad it completely ignores it on the device.
In the preview it looks fine but once it is on a device (ipad) the UITextfield is tiny, its as wide as the one on an iphone.
Judging by the information you provided in your comment, it sounds like you've set the constraints to a set number. I would suggest setting your constraints up using ratios and multipliers. This will make sure the constrained objects are based on the SuperView's size (or rather a percentage of it).
Check out the following links for more information:
This SketchyTech Tutorial
This Make App Pie Tutorial
This Ray Wenderlich Tutorial

Autolayout needed if only support one orientation?

Is Autolayout needed to setup for any subview, if my application only support one orientation (e.g., landscape right), applied for all UIViewControllers?
Yes, of course in the case of using animation I agree. But for the normal case, do I need AutoLayout?
Note: I am using XCode7, Swift, ios9
Understanding Auto Layout
Auto Layout dynamically calculates the size and position of all the
views in your view hierarchy, based on constraints placed on those
views. For example, you can constrain a button so that it is
horizontally centered with an Image view and so that the button’s top
edge always remains 8 points below the image’s bottom. If the image
view’s size or position changes, the button’s position automatically
adjusts to match.
This constraint-based approach to design allows you to build user
interfaces that dynamically respond to both internal and external
changes.
Unless you are making an app for one specific screen size, you will want to
use Auto Layout.
Use cases:
You want to support different size classes.
You want to support different screen sizes.
The content displayed by the app changes.
The app supports internationalization.
The app supports Dynamic Type (iOS).
Most of these changes can occur at runtime, and they require a dynamic
response from your app. Others, like support for different screen
sizes, represent the app adapting to different environments. Even
through the screen size won’t typically change at runtime, creating an
adaptive interface lets your app run equally well on an iPhone 4S, an
iPhone 6 Plus, or even an iPad. Auto Layout is also a key component
for supporting Slide Over and Split Views on the iPad.
Auto layout is not required at all. Even for multiple orientations.
However, If you don't use it, you'll have to manage placement for all the different sized devices yourself. So you might as well use it.

Set object properties depending on Size Class in iOS8

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.

Xcode 6 – Unified storyboard & Size Classes

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)

grow or shrink UIImageView frame to fit the entire iPhone screen via AutoLayout?

So I'm still getting accustomed to the world of Auto Layout in iOS 6 and it's been a fun (or in plain English -- tough) migration coming over from strings & struts.
I have a UIImageView that's the background for a game I'm working on. Here's what a regular 3.5" Retina Display looks like in Interface Builder:
but if I change the "Size" pop-up in the Simulated Metrics field for the content view to "Retina 4 Full Screen", here's what I see:
And you can see the ugly black bar appearing along the bottom edge of the simulated iPhone 5 screen. This same ugly black bar makes it over to the compiled app running in the iPhone 5 simulator.
Are there any attributes or constraints I can apply via Interface Builder to get the UIImageView's frame to size correctly for the appropriate iPhone device screen size?
Or do I have to enter in constraints via code? (ugh)
I've watched the three WWDC videos and if the engineers covered the topic of sizing a view to fit a parent, they must have glossed over it really fast because I've haven't yet found or heard a decent method to get both UIImageView and NSImageView to size correctly to their parent views under both the iOS and MacOS side.
From what you're showing here, I think that what you want to do is drag the image to meet the bottom of the superview so that it takes up all of the space you want. On the bottom right in the IB view you will see a small, grey pill-shaped set of 3 buttons. Click the center one (once you have your imageView selected). It's the one that looks a little like this: |--|. It will bring up a list of constraints. Once you have done that, select "Bottom Space to Superview". You should then be able to switch between phones and have the image resize automatically.

Resources