Autoresizing not working in iOS11 / XCode 9
Asked Answered
C

2

7

It appears that the Autoresizing of views is no longer reliably working when building for iOS11 with XCode 9.

The layout of several views end up with the positioning of controls as they are in the XIB, but the appropriate resizing has not happened. This has been working fine in iOS10, and works with our old app running in iOS11. However, rebuilding the app the positioning and sizing fails.

Has something changed that impacts the use of autoresizingmask?

Is there a way to automatically convert from AutoResizing to AutoLayout and Constraints?

Edit: The controls that are giving trouble are the UINavigationBar and UIToolBar.

Coenocyte answered 18/9, 2017 at 14:31 Comment(1)
Turns out we were digging into the UINavigationBar and UIToolBar to find the internal control, then manually changing it's size (which we shouldn't have been doing). This broke, as Apple has changed the internal structure of these. There still seems to be something going on with resizing though, and I'd like to convert it all to constraints if possible.Coenocyte
O
2

I'm working on this same issue today: one thing that has worked in some cases is swapping out for similar (but not identical) mask values. For example, one of our views didn't work with UIViewAutoresizingFlexibleHeight but it works with UIViewAutoresizingFlexibleBottomMargin.

I'm not aware of an automatic way to upgrade to AutoLayout - I actually use AutoLayout a lot in other projects, and the conceptual basis is pretty different...

I'll edit this answer if I find anything better.

Ostraw answered 20/9, 2017 at 14:37 Comment(0)
C
2

Same issue here. As mentioned by @John Nimis playing with masks sometime seems to solve the problem. For example, when we had both top and bottom masks (UIViewAutoresizingFlexibleTopMargin| UIViewAutoresizingFlexibleBottomMargin) we got success removing the Top one.

EDIT I don't know if this is a definitive solution, but I noticed everywhere the issue happened I had a fixed origin (x or y) on the frame. For example:

view.frame=(view1.frame.origin.x, 150, width, height);

Changing the fixed value in a relative value (for example respect to another view1) solved the issue with masks:

view.frame=(view1.frame.origin.x, view1.frame.origin.y+view1.frame.size.height+20, width, height);

Cultus answered 21/9, 2017 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.