0

我正在运行动画,但我不想在用户触摸屏幕之前开始动画。我想过使用循环,但这需要很多开销,我什至无法让它为此工作。

我知道 touchesEnded 和 touchBegin 方法,但我不确定如何以这种方式使用它们。

提前致谢。

4

2 回答 2

0

您可以在您的视图控制器代码中使用 touchesBegan / Ended,当您触摸屏幕(touchesBegan)或抬起手指(触摸)时它会触发

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//start animation
}
OR
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
//startAnimation
}
于 2012-02-20T01:23:52.063 回答
0

手势识别器是您的朋友:手势识别器

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap:)];
[viewToTap addGestureRecognizer:tapGesture];

- (void) didTap:(UIGestureRecognizer*) sender {
    // start you animation here
}
于 2012-02-20T01:32:29.407 回答