-1

我已经完成了以下操作 - 曾经播放过 QTMovie(在 Mountain Lion 上)并希望在电影结束时收到通知。但通知从未被调用!谁能告诉我我做错了什么?

- (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];
}
4

1 回答 1

1

尝试更改为以下内容(注意 object 参数):

[[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(stopMovie:)
    name:QTMovieDidEndNotification
    object:movie];
于 2013-05-23T23:14:32.017 回答