uiview - iphone - subview rotation problem -


i have uiview root , uiview subview

i don't allow root rotated, write in root class

- (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { return no;} 

but allow root's subview (a) rotated, in class, write

- (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { return yes;} 

but seems both root , subview can't rotate.

how should allow rotated root not?

thanks

views don't answer shouldautorotatetointerfaceorientation, view controllers do. if view controller says rotate view , child views rotate. if view controller says won't rotate view won't rotate , neither children.

there 2 possible approaches solving problem, depending on want do:

  • if non-rotating view behind rotates, remove view controller , add main application window behind view controller upon viewwillappear: , remove again on viewdiddisappear:
  • if non-rotating , rotating views need intermingled in more complicated way, can catch willanimaterotationtointerfaceorientation:duration: , set suitable inverse transform on non-rotating view. rotated , unrotated. you'll need bit tricky correct behaviour between 180 degree rotations because of way coreanimation works.

uiapplication provides means key window uiwindow object, you'd want first idea. uiwindow inherits uiview, standard mechanisms adding , arranging subviews apply.

for latter, you'll want set transform on relevant view. transform superview, inverse , set on view. see cgaffinetransform more specifics. coreanimation issue alluded transition 1 rotation 1 180 degrees different shortest route (as coreanimation take) gives 2 potential solutions — 1 clockwise , 1 anticlockwise. in practice, need add invisible bias view's transform when in portrait mode ensure coreanimation picks right 1 if you're rotating between portrait , portrait upside down. if you're on iphone, it's quite acceptable not support uiinterfaceorientationportraitupsidedown on device (most of apple apps don't), it's easier not support orientation.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -