gpt4 book ai didi

ios - MPMoviePlayerController.view 未从 super View 中删除

转载 作者:行者123 更新时间:2023-11-29 03:47:13 25 4
gpt4 key购买 nike

这是我的代码

- (void)viewDidLoad
{
...
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"mov"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
_moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[self.view addSubview:_moviePlayerController.view];
_moviePlayerController.fullscreen = YES;
_moviePlayerController.scalingMode = MPMovieScalingModeAspectFit;
_moviePlayerController.controlStyle=MPMovieControlStyleDefault;
[_moviePlayerController play];

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

- (void)movieIsOver:(NSNotification *)notification
{
NSLog(@"movie is over");
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self.moviePlayerController.view removeFromSuperview];//moviePlayerController is MPMoviePlayerController
}

当电影播放到最后时,我看不到“电影结束”日志,并且 moviePlayerController.view 没有被删除。我不知道为什么。

编辑:MPMoviePlayerPlaybackDidFinishNotification 运行良好。我看到“电影结束”日志。问题是 moviePlayerController.view 未删除。

最佳答案

我找到了解决方案:添加

_moviePlayerController.fullscreen = NO;

从 super View 中删除 View 之前

关于ios - MPMoviePlayerController.view 未从 super View 中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17590661/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com