Cela semble être un bug dans la version 4.0, il fonctionne correctement lors de la sortie en utilisant le bouton « Terminé ».
La solution de contournement que j'utilise est de stocker manuellement le cadre puis de le restaurer lors de la réception du MPMoviePlayerPlaybackDidFinishNotification
.
Enfin pour l'obtenir en mode paysage, utilisez une sous-classe de MPMoviePlayerViewController
où vous substituez shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
à savoir quelque chose comme ceci:
@interface CustomMoviePlayerViewController : MPMoviePlayerViewController
@end
@implementation CustomMoviePlayerViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft;
}
@end
Et dans votre contrôleur pour contourner le bug:
- (void)playbackEnded:(NSNotification *)notification
{
[[self view] setFrame:[self originalFrame]];
}
- (void)playMovie:(NSString *)movieURLString
{
MPMoviePlayerViewController *controller = [[CustomMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:movieURLString]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackEnded:) name:MPMoviePlayerPlaybackDidFinishNotification object:[controller moviePlayer]];
[self presentMoviePlayerViewControllerAnimated:controller];
}
Merci !!! Je vais essayer. –
Cela a-t-il fonctionné pour vous? – Nuoji
Jetez un oeil à ma solution si vous avez encore un problème – Sid