2

ici est le codeMPMoviePlayerController problème de libération

- (void)applicationDidFinishLaunching:(UIApplication *)application { 
    NSBundle *bundle = [NSBundle mainBundle]; 
NSString *moviePath = [bundle pathForResource:@"sample_mpeg4" ofType:@"mp4"]; 
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain]; 


MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 
moviePlayer.movieControlMode = MPMovieControlModeHidden; 

[moviePlayer play]; 

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(moviePlaybackDidFinish:) 
name:MPMoviePlayerPlaybackDidFinishNotification 
object:nil]; 

} 
- (void) moviePlaybackDidFinish:(NSNotification*)notification 
{ 

MPMoviePlayerController *theMovie = [notification object]; 
[[NSNotificationCenter defaultCenter] removeObserver:self          name:MPMoviePlayerPlaybackDidFinishNotification 
               object:theMovie]; 
[theMovie stop]; 
[theMovie release]; 

[window addSubview:tabBarController.view]; 
[window makeKeyAndVisible]; 
} 

donc mon problème est mon utilisation de la mémoire des applications va 3MB supplémentaires, il y reste même après la libération, que cela signifie la mémoire ne soit pas libéré?

+0

je ne peux pas trouver des ans pour ce que n'importe où – Nnp

+0

un an plus tard, avez-vous trouver une réponse? – 0xDE4E15B

Répondre

1

Regardez votre code dans

- (void) moviePlaybackDidFinish:(NSNotification*)notification 
MPMoviePlayerController *theMovie = [notification object]; 
[[NSNotificationCenter defaultCenter] removeObserver:self          name:MPMoviePlayerPlaybackDidFinishNotification            object:theMovie]; 

Etes-vous sûr "themovie" est que vous avez créé "movieplayer"? Je crois qu'ils sont une adresse de mémoire différente parce que vous n'avez pas assigné un objet lorsque vous enregistrez la notification. Assurez-vous que

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(moviePlaybackDidFinish:) 
name:MPMoviePlayerPlaybackDidFinishNotification 
object:moviePlayer]; 

Ensuite, réessayez.