我用2个for循环创建了30 个按钮 10行 3列, 现在要在按钮上加一个长按手势,应该怎么去找哪个按钮是被长按手势点击的那个
-(void)changeLocktion:(UILongPressGestureRecognizer *)longPress
{
UIButton *btn = (UIButton *)longPress.view;
}
响应长按消息后,用LocationInView等来判断在哪一个按钮的view中。
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self.view];
取出触摸点的坐标,再判断一下就可以了