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: David Duncan <email@hidden>
- Date: Sat, 26 Nov 2016 18:04:52 -0500
What are you trying to accomplish?
For most developers just looking at the aspect ratio in viewDidLayoutSubviews is sufficient. If you only want to do something for rotating, doing it as an alongside animation in viewWillTransitionToSize is usually what you want.
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.
--
David Duncan @ My iPhone
> On Nov 26, 2016, at 3:40 PM, Andreas Falkenhahn <email@hidden> wrote:
>
> When the user rotates the device, I need to reposition my view.
> I do this in viewDidLayoutSubview(). iOS then smoothly rotates
> the view to the new position.
>
> However, in order to reposition my view in viewDidLayoutSubview()
> I need to know whether viewDidLayoutSubview() is called because
> the user has rotated the device or not.
>
> Thus, I set a flag in viewWillTransitionToSize() that tells
> viewDidLayoutSubview() that a rotation is currently in progress.
> This flag is then reset in viewDidLayoutSubview() after it has
> repositioned the view. This works fine but still I feel somewhat
> uneasy about this because I'm not sure whether this is really the
> best way to do this. I'm also worried about potential unwanted
> side effects.
>
> That's why I wanted to ask what is the recommended way to
> reposition my view when the user rotates the device?
>
> I've already done a lot of research on this but I'm still not
> confident about this. Note that I'm not using Interface Builder
> or anything. My app just consists of a single UIView which is
> created manually. The UIView is custom-drawn by setting its
> CALayer to a CGImageRef.
>
> --
> 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
_______________________________________________
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