我有一个应用程序,其中有一个集合视图。单击集合视图时,我将展示另一个视图控制器。这个视图控制器包含一个视频。单击播放按钮时,视频会播放,但是当我单击视频的全屏按钮时,它会崩溃。如果我在应用程序中的任何位置添加视频并单击全屏以使其全屏崩溃,则它会崩溃。
这是我的代码:
- (void) didSelectItemFromCollectionView:(NSNotification *)notification
{
NSDictionary *cellData = [notification object];
UINavigationController *navigationcontroller;
if (cellData)
{
if (!self.detailViewController)
{
self.detailViewController = [[CourseDetailsViewController alloc] initWithNibName:@"CourseDetailsViewController" bundle:nil];
}
self.detailViewController.detailItem = cellData;
[self presentViewController:self.detailViewController animated:YES completion:nil];
}
}
这是从集合视图单元中呈现视频视图控制器的代码。在 coursedetailcontroller 内部。
在 viewDidLoad
-(void)viewDidload
{
MPMoviePlayerController *mc = [[MPMoviePlayerController alloc] initWithContentURL:nil];
mc.shouldAutoplay = NO;
mc.controlStyle = MPMovieControlStyleEmbedded;
NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"01 01. Welcome" withExtension:@"mov"];
mc.contentURL = contentURL;
mc.view.frame = self.test.bounds;
//test is the view where i am displaying the video
mc.movieSourceType = MPMovieSourceTypeFile;
[mc prepareToPlay];
[self.test addSubview:mc.view];
self.testvideo = mc;
}
一切正常,但是当以全屏模式输入视频时,应用程序崩溃。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView trackRectForBounds:]: unrecognized selector sent to instance 0xa45f180' this error message is shown