2010-07-02 85 views
1

我在MPMoviePlayerController中运行了一个介绍电影,并且我分配的内存没有被释放。
电影结束时,乐器显示正在释放的内存。
但是,当我点击它跳过电影的内存不释放。
这里是我的代码的重要部分:MPMoviePlayerController没有发布

- (void)applicationDidFinishLaunching:(UIApplication *)theApplication { 
self.application = theApplication; 
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"mymovie.mov" ofType:nil]; 
NSURL *url = [NSURL fileURLWithPath:urlStr]; 
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; 
[window addSubview:moviePlayer.view]; 


moviePlayer.scalingMode = MPMovieScalingModeAspectFit; 
moviePlayer.controlStyle = MPMovieControlStyleNone; 
moviePlayer.view.frame = window.frame; 


UIView *introFrontView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 
introFrontView.userInteractionEnabled = YES; 
introFrontView.opaque = NO; 
introTabRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self 
      action:@selector(introTabFrom:)]; 
[introFrontView addGestureRecognizer:introTabRecognizer]; 
[moviePlayer.view addSubview:introFrontView]; 
[introFrontView release]; 
[introTabRecognizer release]; 
self.moviePlayerController = moviePlayer; 
[moviePlayer release]; 
[[NSNotificationCenter defaultCenter] addObserver:self 
     selector:@selector(introFinished:) 
     name:MPMoviePlayerPlaybackDidFinishNotification 
      object:self.moviePlayerController]; 
[self.moviePlayerController play]; 
} 

- (void)introTabFrom:(UITapGestureRecognizer*)recognizer{ 
[[NSNotificationCenter defaultCenter] postNotificationName:MPMoviePlayerPlaybackDidFinishNotification 
      object:self.moviePlayerController]; 
} 

- (void) introFinished:(NSNotification*)notification { 
[[NSNotificationCenter defaultCenter] removeObserver:self 
     name:MPMoviePlayerPlaybackDidFinishNotification 
      object:self.moviePlayerController]; 
[self.moviePlayerController pause]; 
[self.moviePlayerController stop]; 
[self.moviePlayerController release]; 
... 
} 

有什么我忘了吗?
以我的理解我发布正确的通知...
任何想法?

回答

0

您可能想要注册MPMoviePlayerPlaybackStateDidChangeNotification,并查看传入的playbackState。