Re: How to detect rotation in progress in viewDidLayoutSubview
Re: How to detect rotation in progress in viewDidLayoutSubview
- Subject: Re: How to detect rotation in progress in viewDidLayoutSubview
- From: Andreas Falkenhahn <email@hidden>
- Date: Sun, 27 Nov 2016 13:25:07 +0100
On 27.11.2016 at 00:04 David Duncan wrote:
> What are you trying to accomplish?
I want to keep my UIView centered on the screen so I need to
change its position when the device rotates. I'm currently
moving the UIView to the new position using
[myView setFrame:...];
in viewDidLayoutSubviews().
> For most developers just looking at the aspect ratio in
> viewDidLayoutSubviews is sufficient.
Right, this would probably be a nicer way than using a flag.
> If you only want to do
> something for rotating, doing it as an alongside animation in
> viewWillTransitionToSize is usually what you want.
Do you mean that I should move the UIView in my "animateAlongsideTransition"
block instead of viewDidLayoutSubviews()? This seems to work as
well but I don't really know anything about those animation
handlers so I felt more comfortable doing this in viewDidLayoutSubviews().
> Also from your last thread, if you are trying to fix up a
> transform, it may be easier to use contentMode instead of transform
> for this case. AspectFit vs AspectFill will do the common letterbox
> vs clip without you needing to do anything further.
Yes, I'm actually using contentMode now. If this is set to
UIViewContentModeScaleToFill, I can just change the bounds
of the UIView and I'll get GPU-accelerated scaling for free.
--
Best regards,
Andreas Falkenhahn mailto:email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden