How to rotate UIButtons 90 degrees without auto layout error?

I have several UIButtons in an array of collections that I want to rotate with this code:

for(UIButton *button1 in b90){ button1.transform = CGAffineTransformMakeRotation( ( 90 * M_PI ) / 180 ); } 

Unfortunately this will not work. It works if I give it values ​​that will rotate it 180 or 360 degrees, for example. pi or 2 pi, etc. (this basically means that the button will be in the same place), but if I give it any other values ​​that leave the button in a distorted orientation, I get this error:

The application terminated due to the unannounced exception "NSInternalInconsistencyException", reason: "Autolayout does not support intersecting rotation boundaries, limits layout boundaries such as right, left, top, bottom. Offensive view:> '

The details of the frame and the transformations are explanatory. I think it just says that he doesn’t want the buttons to be skewed at all. I can avoid the problem by decrypting the "Use Autostart" button in the xib file, but this makes the rotary buttons look jagged. If you disabled iDevice at runtime, you can turn it back for some reason, but that is not what I want.

Any ideas on how to lower the buttons and not turn off the "Use autorun" option?

All help is much appreciated and I always check the best answer!

+4
source share
1 answer

I use the same statement and it works for me:

 #define DEGREES_TO_RADIANS(d) (d * M_PI / 180) btn.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90)); 

I think you are using iOS 6.0 code in which auto-linking is enabled with old xcode.

Can you provide more details about this?

thanks

+4
source

Source: https://habr.com/ru/post/1436987/


All Articles