How to detect rotation in progress in viewDidLayoutSubview
How to detect rotation in progress in viewDidLayoutSubview
- Subject: How to detect rotation in progress in viewDidLayoutSubview
- From: Andreas Falkenhahn <email@hidden>
- Date: Sat, 26 Nov 2016 21:40:54 +0100
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