次のコードは、はるかに大きなコードから抜粋したものですが、このセクションが問題を引き起こしていると思います。実行するとエラーは発生しませんが、実行されるはずの「playMovie」内のハードコードされたボタンを押すと、「exit movie」というメッセージが表示されます。 :]: 認識されないセレクターがインスタンス 0x7a4b350 に送信されました' 私はこれについていくつかの調査を行い、これを行う理由を見つけましたが、私のケースを理解できないようです. 私は初心者のコーダーですが、おそらく何かが足りないだけです。これで問題が解決することを願っています。そうでない場合は、さらにコードを送信できます。
-(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];
}