Set different constraints for Different Size classes - ios

I have use the storyboard to create an UI for application. I set the constraints for wCompact hAny and now I want to set different constraints for wCompact hRegular(iphone6+). For this what should I have to do. Please give me any example for this.

You just change you the size and update the constraints accordingly. This will save and be loaded according to the size.

Related

Using auto layout constraint priorities to change the size of a view on different devices

I am using autolayout to create a UI. I am setting some constraints there.
In the above image, as you can see there, is a image view in the center. Now I want to set the size of the image view not proportional on iPad. I want to set its size slightly bigger than the iPhone 5, and in the center of the view. I want to use priorities here. How can I achieve that?
Hey you can use size classes for such kind of work. In iPad apply different constraint as you need.Follow the below for complete reference to this:https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html

Constraints collision between size classes

I want to create constraints which simply create a vertical space between two views.
First I create it in the wAny hAny size class with a space of 40.
Then I want to have the same constraint with other values in other size classes.
But when I create the same constraint, just with another value Xcode gives me an
auto-layout error that those constraints are colliding.
Because wAny hAny is valid in all other size-classes as well.
In a first attempt I have deleted the constraint out of the wAny hAny size class but then I get the
auto-layout error that the layout is not defined correctly in wAny hAny.
So, it does not matter how I create it, there is always an auto-layout error. I think I just missed a basic concept here to understand what is going wrong. Can somebody explain it to me?
Thanks.
I have found the problem. I was doing it wrong. What I have done is - changing the size-class by selecting the size-class in IB (clicking on wAny hAny at the bottom of the IB screen) and then just set another constant value. This does not work.
This is how it works. Go to the size inspector and click on the plus sign on the left of the constant. Now add the size class. This creates a second constant for the new size class.
Now setting the value on the second constant does work. The original hAny wAny size class is not affected.

Can I add constraints based on size class in viewDidLoad programmatically?

Previously I used adaptive layout in my project using size class, I were able to add/install constraints based on the size class.
But now I am adding constraint in viewDidLoad. I want to use adaptive layout feature without using XIB file.
Is that possible ?

Change constraint target class

I designed lots of constraints for my iOS app. Now the app works properly on all iPhone in portrait mode. I designed the constraints for the xCompact hRegular class. I realized, unfortunately only now, that all those constraints would be perfect also for all iPad in portrait. So, how can I change the constraints target class without recreating all of them for the more generic wAny hAny class? Thank you.
Select a constraint. In the last property in the attributes inspector, XCode shows you a list of check boxes with the size classes for which the constraint is active. The first check box represents wAny hAny, select it and repeat this for each constraint.

[iOS]Can I change the size of a freeform UIViewController on code?

I want to change the size of UIViewController whose size has already set in storyboard as freeform.
I need to remove some subviews after I get a certain result from a server.
Originally the size is 320x750 but it sometimes will be reduced to 320x500.
I use autolayout.
Any suggestions?
I would remove autolayout and then use
setPreferredContentSize:(CGSize)
If you want to keep autolayout, you'll have to programatically add constraints.

Resources