よろしくお願いします。の奇妙な行動を共有したいと思いUILongPressGestureRecognizer
ます。
UIView *v = [UIView alloc] initWithFrame:CGRectMake(0,0,20,20)];
UILongPressGestureRecognizer *longpressGesture1 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[v addGestureRecognizer:longpressGesture1];
ここでは、ジェスチャ レコグナイザーを処理するデリゲートです。
-(IBAction)tapped:(UILongPressGestureRecognizer *) gesture
{
switch ([gesture state]) {
case UIGestureRecognizerStateBegan:
{
NSLog(@"Long Tap detacted.");
}
break;
case UIGestureRecognizerStateChanged:
{
NSLog(@"UIGestureRecognizerStateChanged");
}
break;
case UIGestureRecognizerStateEnded:
{
NSLog(@"Long Tap ended.");
}
break;
}
}
このコードは、iOS 4 および 5 では期待どおりに完全に機能しますが、Retina ディスプレイを搭載した iOS 6 では、長いタップを実行するUIGestureRecognizerStateBegan
と、1 回の長いタップに対して 2 回呼び出され、アプリケーションがクラッシュします。どんな助けでも大歓迎です。