0

I have a small view on top of an mpmovieplayercontroller. When it is not fullscreen, I am able to adjust the frame of the view to the orientation (when the device rotates). But when I enter fullscreen mode, alothough I manage to present the view, I'm no longer able to maintain the correct frame when the device rotates. It looks like in fullscreen mode, the system simply using CGAffineTransformRotate on the status bar and the moviePlayer. How can I apply this CGAffineTransformRotate to rotate my view correctly?


EDIT:

Ok, so I updated the code to rotate 90% in the X axis after a change in orientation of the mpmovieplayercontroller but the view simply disappears after the first rotate. Here is my code:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{


     float   angle = M_PI / 2;  //rotate 180°, or 1 π radians
     theView.layer.transform = CATransform3DMakeRotation(angle, 1.0, 0.0, 0.0);


    [self changePositionBasedOnOrientation:toInterfaceOrientation]; //here we change the frame of the view


}
4

2 回答 2

2

我不确定这是否一定是正确的方法(我猜你正在向视图添加子MPMoviePlayerController视图?),但你似乎是在回调电影播放器​​全屏旋转时的回调所以您可以调整自己的自定义视图。

您可以在自定义视图上注册旋转通知,然后每次收到回调时都可以自行调整。您注册轮换通知如下:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(layoutViewForOrientation:)
    name:UIDeviceOrientationDidChangeNotification
    object:nil];

endGeneratingDeviceOrientationNotifications完成全屏模式后,您应该记住并删除通知观察者。

于 2011-04-03T10:02:31.307 回答
2

好的,

因此,以全屏方式覆盖 mpmovieplayercontroller 的最佳方法是这样:

[[[[[UIApplication sharedApplication] keyWindow] subviews] objectAtIndex:0] addSubview:mySubview]

这有点hacky,但合法。它为您提供了一种处理旋转的简单方法(而不是使用转换)。

于 2011-04-11T14:40:03.910 回答