我使用touchesBegan:withEvent:
来获取用户在屏幕上的触摸,但是当我触摸按钮时,不会调用此方法。有没有办法确定点击了哪个按钮?
修改
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch *touch = [[touches allObjects] objectAtIndex:0];
CGPoint finger = [touch locationInView:self];
int x = finger.x;
int y = finger.y;
}
这是touchesBegan:withEvent:
方法。我给每个UIButton一个标签号。我确实在界面构建器中连接了UIButton。