0
我一直在试图解决这个问题 - 我正在用MoviePlayerViewController播放一些视频,但当我试图通过加速度计来播放随机视频时,我得到了一个崩溃试图切换到新电影。MoviePlayerViewController转换导致崩溃
下面是播放影片的代码:
-(void)playMovieAtURL:(NSURL*)theURL {
MPMoviePlayerViewController* theMovie=[[MPMoviePlayerViewController alloc] initWithContentURL:theURL];
if (theMovie){
[self presentMoviePlayerViewControllerAnimated:theMovie];
theMovie.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[theMovie.moviePlayer play];
[theMovie release];
}
}
这里是加速度计代码:
- (void) accelerometer: (UIAccelerometer *)accelerometer didAccelerate: (UIAcceleration *)acceleration {
if (self.lastAcceleration) {
if (!shakeDetected && IsDeviceShaking(self.lastAcceleration, acceleration, 0.7)) {
shakeDetected = YES;
NSLog(@"Shake detected");
int filescount = [entries count];
int randomIndex;
for(int index = 0; index < filescount; index++)
{
randomIndex= arc4random() % filescount;
[entries exchangeObjectAtIndex:index withObjectAtIndex:randomIndex];
}
AppRecord *app = [entries objectAtIndex:randomIndex];
contentController.detailItem = app;
[self playMovieAtURL:[NSURL URLWithString:app.applink]];
}
else if (shakeDetected && !IsDeviceShaking(self.lastAcceleration, acceleration, 0.2)) {
shakeDetected = NO;
}
}
self.lastAcceleration = acceleration;
}
,当它在这个位置切换视频发生崩溃:
[self presentMoviePlayerViewControllerAnimated:theMovie];
当我改变视频时调试器错误是:
由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'尝试在转换已经进行时从UINavigationController到MPMoviePlayerViewController开始模态转换。等待viewDidAppear/viewDidDisappear知道当前转换已完成'
任何建议和想法,非常感谢。谢谢!!
您是否找到了解决此问题的方法(除了稍后调用某种方法的某些方法之外)? – stk 2012-12-20 15:46:44