0
下面的代碼是從更大的代碼中提取的,但我相信這是給我帶來麻煩的部分。當我運行它時,我沒有得到任何錯誤,但是當按下想要執行的'playMovie'內的硬編碼按鈕時,'退出電影'我得到消息:由於未捕獲的異常'NSInvalidArgumentException',原因:' - [ViewController exitMovie :]:無法識別的選擇發送到實例0x7a4b350'我已經做了一些研究,並找到了它的原因,但我似乎無法理解我的情況。我是一個新手編碼器,所以我可能只是想念一些東西。希望這足以解決問題,如果不是我可以發送更多的代碼。SIGABRT正在播放電影
-(IBAction)playMovie{
UIButton *buttonPress = [UIButton buttonWithType:UIButtonTypeCustom];
[buttonPress addTarget:self
action:@selector(exitMovie:)
forControlEvents:UIControlEventTouchUpInside];
buttonPress.frame = CGRectMake(0.0, 0.0, 1000.0, 1000.0);
buttonPress.backgroundColor = [UIColor clearColor];
[self.view addSubview:buttonPress];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"We_Cant_Elope" ofType:@"mov"]];
MPMoviePlayerController *playerViewController = [[MPMoviePlayerController alloc] init];
playerViewController.contentURL = url;
playerViewController.view.frame = CGRectMake(120,300, 550, 400);
[self.view addSubview:playerViewController.view];
[playerViewController play];
self.playerViewController = playerViewController;
}
-(IBAction)exitMovie{
[self.playerViewController.view removeFromSuperview];
[self.playerViewController stop];
}