Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Thomas Harte

macrumors 6502
Original poster
Nov 30, 2005
401
19
What I want to do: within a view controller, upon notification that an interface rotation is going to occur, have a view instantly adopt a starting state state (different from the one it had before), then animate to a final state within the standard rotation animation block.

Reasoning is that I have a subview of a rotating view controller that I want not to rotate. I can achieve that in most cases by setting that view with the inverse transform of its superview in willAnimateRotationToInterfaceOrientation. However, in rotations by 180 degrees (ie, one portrait to the other or one landscape to the other) I run up against the problem that Core Animation may rotate clockwise or anticlockwise at its own discretion, as neither route is 'shorter'. I wish to give my view a tiny pre-nudge in the right direction to ensure Core Animation does the right thing.

What I've tried:
  1. setting the start state within shouldAutorotateToInterfaceOrientation, setting the final state within willAnimateRotationToInterfaceOrientation
  2. setting the start state within willRotateToInterfaceOrientation, setting the final state within willAnimateRotationToInterfaceOrientation

Neither works as is. If I set willAnimateRotationToInterfaceOrientation to do nothing for the first few calls then hooking in willRotateToInterfaceOrientation works exactly once — in the animation that results the very first time that willAnimateRotationToInterfaceOrientation actually acts.

If I set the nudge to be unnoticeably small and place it in didRotateFromInterfaceOrientation then everything is fine, but I'm worried that since my view then isn't exactly oriented at a multiple of 90 degrees (even though it looks like it is), it may not go down the fast compositing route that Apple engineers have referenced at various tech talks, etc.

So, question is: is there any usable and reliable warning that a view controller animation rotation is about to occur that is positioned at a suitable place in the runloop to allow a change to the UIView transform to take effect rather than be silently ignored?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.