【发布时间】:2012-02-23 18:32:37
【问题描述】:
我正在开发一款游戏,其中通过长按对象本身来设置游戏对象的属性。该属性的值由长按手势的持续时间决定。我为此目的使用了 UILongPressGestureRecognizer,所以它是这样的:
[gameObjectView addGestureRecognizer:[[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handle:)]];
然后是处理函数
- (void)handle:(UILongPressGestureRecognizer)gesture {
if (gesture.state == UIGestureRecognizerStateEnded) {
// Get the duration of the gesture and calculate the value for the attribute
}
}
在这种情况下如何获取长按手势的持续时间?
【问题讨论】: