私は、表示する必要があるユーザー インタラクション用の一連のビデオとその間の画像があるプロジェクトに取り組んでいます。最初は問題なく動作しますが、アプリを 2 回目に実行すると、ユーザーの操作がスキップされます。私は現在、このコードに取り組んでいます:
-(void) playScene
{
if([scenetype isEqualToNumber:[NSNumber numberWithInt: 0]])
{
// plays a video using AVPlayer
...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nextScene:)
name:AVPlayerItemDidPlayToEndTimeNotification object:Nil];
}
else
{
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.jpg"]];
imageView.frame = View.bounds;
imageView.userInteractionEnabled = YES;
tapImage = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(checkTouch:)];
[imageView addGestureRecognizer:tapImage];
[View addSubview:imageView];
}
}
チェックタッチ方式で・・・
-(void)checkTouch: (UITapGestureRecognizer *) gesture
{
CGPoint location = [gesture locationInView:imageView];
if(location.x > 20.0 && location.x < 50.0)
{
//somedata
...
[self playScene];
}
else
{
...
[self playScene];
}
}
そして最後に次のシーンで:
-(void) nextScene: (NSNotification *) anotification
{
if(nextscene)
{
//somedata
...
[self playScene];
}
else
{
exit(0);
}
}
if 条件が true でない場合に画像を表示しますが、ユーザー インタラクション メソッドをスキップし、nextScene() メソッドに入り、画像の上でビデオが再生されます。ここで何が欠けていますか?どんな助けでも大歓迎です。