[英]Send button on Long press gesture
如何长按手势发送按钮名称,标签或文本? 我需要知道长期以来的按钮名称。
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTagS:[[ToalData objectAtIndex:i] objectAtIndex:4]];
[button addTarget:self action:@selector(siteButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
///For long//
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleLongPress:)];
longPress.minimumPressDuration = 1.0;
[button addGestureRecognizer:longPress];
////
NSString *string1 = [NSString stringWithFormat:@"%@", [[ToalData objectAtIndex:i] objectAtIndex:1]];
[button setTitle:string1 forState:UIControlStateNormal];
button.frame = CGRectMake(XLocatioan, YLocation, 90, 30);
[self.view addSubview:button];
(void)handleLongPress:(UILongPressGestureRecognizer*)sender
{
if (sender.state == UIGestureRecognizerStateEnded)
{
NSLog(@"UIGestureRecognizerStateEnded");
}
else if (sender.state == UIGestureRecognizerStateBegan){
NSLog(@"UIGestureRecognizerStateBegan");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.