UILongPressGestureRecognizer hareketi tetiklendiğinde UIButtons'un sürüklenip bırakılabileceği bir uygulama oluşturmaya çalışıyorum.UILongPressGestureRecognizer
Ben: Bu bir düğme (yani ivar button
) ile büyük işler
UIGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handleLongPress:)];
Ve
- (void)handleLongPress:(UILongPressGestureRecognizer *)recognizer {
CGPoint location = [recognizer locationInView:self.view];
switch (recognizer.state) {
case UIGestureRecognizerStateBegan:
//NSLog(@"handleLongPress: StateBegan");
break;
case UIGestureRecognizerStateChanged:
if(location.y > 75.0 && location.x > 25 && location.x < 300)
button.frame = CGRectMake(location.x-25, location.y-15, 50, 30);
break;
case UIGestureRecognizerStateEnded:
//NSLog(@"handleLongPress: StateEnded");
break;
default:
break;
}
}
. HandleLongPress işlevine basılan geçerli düğmeye nasıl gönderebilirim? Ben Sen handleLongPress içine tüm düğmesi aracılığıyla döngü gerekecek sender
- (void)handleLongPress:(UILongPressGestureRecognizer *)recognizer:(id)sender {
CGPoint location = [recognizer locationInView:self.view];
switch (recognizer.state) {
case UIGestureRecognizerStateBegan:
//NSLog(@"handleLongPress: StateBegan");
break;
case UIGestureRecognizerStateChanged:
if(location.y > 75.0 && location.x > 25 && location.x < 300)
sender.frame = CGRectMake(location.x-25, location.y-15, 50, 30);
break;
case UIGestureRecognizerStateEnded:
//NSLog(@"handleLongPress: StateEnded");
break;
default:
break;
}
}
Bu işe yaradı. Teşekkürler! – v0idless
@ v0idless: Hoş Geldiniz. – EmptyStack