Objective-c – uibutton with touchesBegan

iphoneobjective c

I use touchesBegan:withEvent: to get the touches of the user in the screen but when i touch a button this method isn't called. Is there any way to identify which button was clicked?

edit:

-(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;

}

This is the touchesBegan:withEvent: method. I gave each UIButton a tag number. And I did connect the UIButton in the interface builder.

Best Answer

Please, look at this question. Exactly what you need.

Related Topic