开发者

MPMoviePlayerController Done button unresponsive in Landscape mode

开发者 https://www.devze.com 2023-02-07 18:46 出处:网络
All, The Done button in MPMoviePlayerController dismisses the control in portrait mode. However, both the Done and Toggle full screen button become unresponsive when i rotate to landscape.

All, The Done button in MPMoviePlayerController dismisses the control in portrait mode. However, both the Done and Toggle full screen button become unresponsive when i rotate to landscape. My app is a very very simple app and just has didRotatefromInterfaceOrientation method where i change the movie frame width and height to landscape and change the origin to match landscapemode.

`- (void)didRotateFromInterfaceOrientat开发者_运维百科ion:(UIInterfaceOrientation)fromInterfaceOrientation { // Update the frame of the view. CGRect newFrame = [[UIScreen mainScreen] applicationFrame];

newFrame.origin.x = - (newFrame.size.width / 2);
newFrame.origin.y = - (newFrame.size.height / 2);

[[self view] setBounds:newFrame];
[[self view] setCenter:CGPointMake( [[self view] bounds].size.width / 2, [[self view] bounds].size.height / 2)];
[self view].userInteractionEnabled = YES;

// Update the frame of the movie player.
newFrame = [[UIScreen mainScreen] applicationFrame];
if( fromInterfaceOrientation == UIInterfaceOrientationPortrait || fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
    newFrame.size.width = newFrame.size.height;
    newFrame.size.height = [[UIScreen mainScreen] applicationFrame].size.width;
}
newFrame.origin.x = - (newFrame.size.width / 2);
newFrame.origin.y = - (newFrame.size.height / 2);
[[[self moviePlayer] view] setFrame:newFrame];
[[[self moviePlayer] view ] setUserInteractionEnabled:YES ];

}`


Well the problem here was that i was rotating the view and resizing it in `- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation. You are not required to do that as the movie player automatically does that for you. Resizing and rotating the frame actually got the button confused and hence did not receive touch events when tapped.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号