objective c - How to animate rotation of MPMoviePlayerController? -


i'm making video player ipad , i'm having trouble animating rotation properly. deal rotation setting auto rotation mask, since i'm working video player want preserve aspect ratio , i'm not sure how auto rotation mask.

i did quick , dirty solution without animation correct behavior:

- (void)didrotatefrominterfaceorientation:(uiinterfaceorientation)frominterfaceorientation {     movieplayer.view.frame = cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.width*0.75); } 

it works correctly, it's not pretty. i'm preparing app demo, working correctly isn't enough, has pretty.

i tried following , think can guess why doesn't work:

- (void)willrotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration {     [uiview animatewithduration:duration animations:^{         movieplayer.view.frame = cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.width*0.75);     }]; } 

that's right, self.view.frame hasn't been updated yet.

any advice on how deal this, without hard coded frames?

there may cleaner way this, calculate new frame should using current one, , new orientation:

- (void)willrotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration {   cgsize size = self.view.frame.size;   cgrect newrect;   if (tointerfaceorientation == uiinterfaceorientationportrait || tointerfaceorientation == uiinterfaceorientationportraitupsidedown) {     newrect = cgrectmake(0, 0, min(size.width, size.height), max(size.width, size.height));   } else {     newrect = cgrectmake(0, 0, max(size.width, size.height), min(size.width, size.height));   }    [uiview animatewithduration:duration animations:^{     player.view.frame = newrect;   }]; } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -