2011-07-12 6 views

答えて

0

会社があなたのボタンに2つのアクションを設定し、これらの2つの方法の間を通過する時間を測定することができますが呼び出されます。

UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
btn.frame = CGRectMake(100.0, 100.0, 100.0, 20.0); 
[btn setTitle:@"Test" forState:UIControlStateNormal]; 
[btn addTarget:self action:@selector(userEndsTap:) forControlEvents:UIControlEventTouchUpInside]; 
[btn addTarget:self action:@selector(userStartsTap:) forControlEvents:UIControlEventTouchDown]; 

、あなたのデュレーションの測定を行うことができます呼び出される二つの方法で:

- (void)userEndsTap:(id)sender { 
    NSLog(@"user ends tap"); 
    // stop measurement an do something different for different durations 
} 

- (void)userStartsTap:(id)sender { 
    NSLog(@"user starts tap"); 
    // start measurement 
} 
1

ボタンにUILongPressGestureRecognizerを添付し、minimumPressDurationプロパティを設定します。 同じボタンに複数のジェスチャ認識機能を追加することができます。

異なるジェスチャ認識プログラム間に「競合」がある場合は、–requireGestureRecognizerToFail:を使用してそれらを解決し、別のジェスチャ認識プログラムが認識されない場合にのみジェスチャが認識されるように指定できます。

relevant documentをご覧ください。