我做了以下事情 - 曾经在山狮上演过QTMovie,想在电影结束时收到通知。但通知从未被召唤过!谁能告诉我,我做错了什么?
- (void)playMovie:(QTMovie *)movie {
[self.movieView.movie stop];
if (movie) {
self.movieView.movie = movie;
[movie gotoBeginning];
[movie play];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stopMovie:) name:QTMovieDidEndNotification object:self];
}
}
- (void)stopMovie:(NSNotification *)notification {
NSLog(@"stop movie!");
[[NSNotificationCenter defaultCenter] removeObserver:self name:QTMovieDidEndNotification object:nil];
}
答案 0 :(得分:1)
尝试更改为以下内容(请注意对象参数):
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(stopMovie:)
name:QTMovieDidEndNotification
object:movie];