背景图片是动画的天空
在设置页面(静态图像)和主页(动画图像)之间切换时,屏幕动画通常会掉落并变成单个黑色图像
有人可以提出原因或解决方案吗?
谢谢!
亨利色彩视觉应用
- (void)viewDidLoad
{
[super viewDidLoad];
self.mp = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"iPhone4" ofType:@"mov"]]];
mp.repeatMode = MPMovieRepeatModeOne;
[mp.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
mp.scalingMode = MPMovieScalingModeFill;
[mp setFullscreen:YES];
mp.controlStyle = MPMovieControlStyleNone;
[self.view addSubview:mp.view];
[self.view sendSubviewToBack:mp.view];
[mp prepareToPlay];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.mp play];
}
最佳答案
尝试将观察者添加到播放器中。像这样:
- (void)viewDidLoad
{
///...
self.mp = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"iPhone4" ofType:@"mov"]]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.mp];
///...
}
然后,您可以找到问题所在:
- (void)moviePlaybackComplete:(NSNotification *)notification
{
NSLog(@"Movie Finished.");
int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
if (reason == MPMovieFinishReasonPlaybackError) {
NSDictionary *notificationUserInfo = [notification userInfo];
NSError *mediaPlayerError = [notificationUserInfo objectForKey:@"error"];
if (mediaPlayerError)
{
NSLog(@"playback failed with error description: %@", [mediaPlayerError localizedDescription]);
}
else
{
NSLog(@"playback failed without any given reason");
}
}
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:self.mp];
}
关于iphone - MPMoviePlayerController-切换 View 时黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14931949/