klefevre
klefevre

Reputation: 8735

CGAffineTransformMakeRotation and UIViewController Rotation predicament

I've got a problem. I've an UIImageView and i do some rotation to it with CGAffineTransformMakeRotation(). Not problem with that. But when i do a rotation with my UIViewController (portrait to landscape and/or inverse). My UIImageView is modified strangely.

Its frame become change from :CGRectMake(50.f, 50.f, 150.f, 150.f) to a frame like :CGRectMake(50.f, 123.2f, 1004.56f, 1530.456f)

I realize that changes happens when I do UIViewController rotation when i've done a rotation on my UIImageView not equal to 0, 90, 180, or 270

I think it's because the UIViewController change the rect of the UIImageView but how inhibit that comportement


Unfortunately my view move/change visually. That's my problem and why I'm talking about that here... I spoke about the frame property because I notice it changed strangely (and randomly) and even if I changed it after to my original frame. The view doesn't seem 'listen' to it. I hope I am well. Anyone for a solution ?

Upvotes: 1

Views: 811

Answers (2)

jstevenco
jstevenco

Reputation: 2953

It's not clear from your description, but it sounds as if your UIImageView is a subview of the view owned by your UIViewController. Unless you have a reason to not manage it this way, I'd suggest setting the UIImageView struts and springs (i.e., its autoresizingMask) to surface the desired behavior and then allow the parent view to reposition/resize the UIImageView.

Upvotes: 1

Sean
Sean

Reputation: 1272

If you set a view's transform property to anything but the identity matrix (which you must have done in order to rotate it), the frame property becomes undefined and should be ignored. This is noted in the documentation. Is it just the frame property that goes wrong or is the view moving/changing visually in some unexpected way as well?

Upvotes: 2

Related Questions