xCode 8 Story Board Problems

I've been trying to figure out how to add constraints for different class sizes for 4 days now and still cant figure this out. Here's my problem. I need different constraints for wC hR and wR hR, iPhone and iPad. If I set constraints for C R I get no errors. As soon as I set constraints for R R xCode shows no errors for that as well but the constraints for C R are now messed up. If I fix C R then R R shows errors. I can go back and forth all day long but corrections in either size class messes up the other. When I look at the preview in assistant editor the only preview to display correctly is the one that corresponds to the device my story board displayed in. I find it hard to believe Im doing something wrong because once I set constraints for both size classes and despite the errors in one or the other the layouts work correctly on the simulator and all the devices.


I've been through Stack Overflow and the developer forums and see others are having similar problems. I've read through Apple's documentation and watch videos from the WWDC as well s other tutorials on line and youtube but still can't figure out how to add constraints to a size class with causing errors in the others.


As I said, even though I get errors in one size class on the story board and the preview doesn't properly display the layout everything seems works fine on the devices and simulator. So, has anyone had a similar problem, found a way to do all this with out errors, know of a tutorial I can look at or could this be a bug in xCode.


Any help would be greatly appreciated.

Glenn

Answered by HugoPT in 183829022

Hi

Perhaps this can help you finding the way.

https://makeapppie.com/2016/09/05/an-introduction-to-size-classes-for-xcode-8/

happy coding

Accepted Answer

Hi

Perhaps this can help you finding the way.

https://makeapppie.com/2016/09/05/an-introduction-to-size-classes-for-xcode-8/

happy coding

Thanks for the link. I have actually read this tutorial but havn't had much luck untill I tried xCode 8.1 beta. It seems to be better but still have some issues.

Sorry the tutorial wasn't enough. I'll be fixing that in the Practical Autolayout book update.

Dont set the height constraint unless you have to -- that's phone in landscape. Best strategy for handling class sizes is:

  1. Make your Width:compact first as the defalut.
  2. Select the iPad. Vary for the Horizontal constraint only. Change your views for the iPad arrangement.
  3. Select a phone in landscape. You have two choices at the next point. if you want a different layout for iPHone plus in landscape than the othere phones, vary constraints for both horizontal and vertical. If you dont' vary only the vertical. Change the constraints.
  4. Select the iPhone PLus in landscape. While you avoided conflicting constraints, you may not have here if step three was only the vertical constraint. Select for both horizontal and vertical, and fix the layout. for width regular height compact.

That will keep the conflicting constraints to a minimum.

Nothing wrong with the tutorial. Guess I just had to change the way I work and like I said the beta version of xCode helped too. By the time I get all this down Apple will probably change it again for xCode 9. Thanks for the help.

Hi grthomas,


Did you manage to solve your problem?


Because if you did, it would love to hear your solution, since I'm having a similar problem myself. I don't need to vary constraints for compact or regular devices, but when I add constraints, all works perfectly in the simulator, but in Storyboard Preview it doesn't. All devices, except the one my layout was initially made for, show something different than they're supposed to, but when I use those devices in simulator they all work exactly as they should.


Thank you in advance,

Maikel Versantvoort

xCode 8 Story Board Problems
 
 
Q