Kodeco Forums

Video Tutorial: Adaptive Layout Part 2: Constraints

Learn how to customize the position and size of our views for different Size Classes by adding new constraints and uninstall existing constraints based on Size Class.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3187-adaptive-layout/lessons/3

Is there a way we can edit a constraint for a particular size class? Let me give an example - Suppose I have a constraint whose constant value is 20 for all size classes. I want to make it 8 for a few size classes. Can I do that?

Yes, if you double-click on the constraint, next to the “Constant” field, there should be a “+”. If you click that you can specify a new value for a size class. Once you pick the size class, you can enter a new value. It’s very similar to the challenge from video 1, just using the “constant” field instead of the “installed” checkbox.

I’ve created a very simple webview app which works perfectly on iPhone5 - but of course looks a bit rubbish on any other size screen.

I am trying to use this technique to fill the screen on an iPhone 6 and squeeze my iPhone 5 webview onto an iPhone4 screen.

Any reason why it should not work ? Obviously my graphics will be stretched or squeezed slightly but that’s better than white space or not fitting !

You should be able to use auto and adaptive layout to get the size of the web view itself to fill the space, but for the content, you’ll have to use css or html to move the content.

All versions in Resources crash on startup at:

mapView.setRegion(region, animated: true)

this was mentioned last year in the discussion thread also. What would be the fix?

Thanks

Sorry, I must have missed the last time it was mentioned. If you remove all the code from the ViewController class, it should fix the issue. That MapKit code is for a future step and doesn’t need to be there at this point.

Ok, the resources link on the site has been updated to remove this code. Sorry for the error.

There is no link to the next topic in this slide set.

Sorry for the missing link to video 3! I’ve now added it to the post.