iPhone初心者です。
ボタンに長押しジェスチャとクリック イベントの両方を追加したいのですが、可能ですか?
両方のイベントをボタンに追加してから長押しすると、クリック イベントが発生しますが (クリックすると新しいページに移動します)、長押しイベントは発生しません。
ここに私のコードスニペットがあります:
button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(xpos, ypos, 120,130);
[button setBackgroundImage:[UIImage imageNamed:@"ibook2.png"] forState:UIControlStateNormal];
[button setTitle:[NSString stringWithFormat:@"32"]];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchDown];
LongPress = [[UILongPressGestureRecognizer alloc] init];
[LongPress addTarget:self action:@selector(longPressDetected:)];
LongPress.delegate = (id<UIGestureRecognizerDelegate>)self;
[button addGestureRecognizer:LongPress];
[LongPress release];
[self.view addSubview:button];
両方のイベントを追加するにはどうすればよいですか?
どんな助けでも大歓迎です。