0

I'm trying to use size classes in the new storyboard with auto layout and I cannot seem to make the constraints work properly. I have a game that uses a ton of collision and currently without autolayout it only scales properly on iPhone 5. When I change to iphone 4 or iphone 6 or any other layout, the storyboard gets cut off on the side. I tried to fix this by using autolayout, but when I select it, it completely ruins all the collision. It brings the object back to where it originally is in the storyboard and then applies all collision.

On top of that, it seems like there is no clearcut way to resize it with autolayout/size classes (unless i'm missing it somewhere). Is there a good tutorial on working with constraints in xcode 6 so that the collision isn't completely reset/ruined and it scales for all ios devices?

  • It sounds to me like you are noticing the conflict between auto layout and animation / transforms / movement of views by their frames. This is a fundamental conflict, not easy to resolve. See my essay here: http://stackoverflow.com/questions/12943107/how-do-i-adjust-the-anchor-point-of-a-calayer-when-auto-layout-is-being-used/14105757#14105757 – matt May 29 '15 at 17:34

1 Answers1

0

If you turn on Autolayout you will be unable to move any view (by manipulating its frame) that has a constraint applied to it. So assigning a new CGRect to a UIView won't move an object if that object has an X,Y constraint set.

You'll instead need to create IBOutlets for each constraint that you want to move or resize. So create some outlets like

yourViewConstraintX;
yourViewConstraintY;

And then you can update them with self.yourViewConstraintX.constant = 20;

Adama
  • 1,101
  • 8
  • 26