3

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.

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
yosifz8
  • 551
  • 2
  • 7
  • 11
  • How did you go about implementing this? We need a bit more info. – Deepak Danduprolu May 29 '11 at 21:00
  • If you posted some code it would help, also, if you use InterfaceBuilder have you remembered to connect the outlets? – LuckyLuke May 29 '11 at 21:05
  • buttons consume the touches and do not pass it along. If you can tell what is it that you're trying to do, we can help you find an optimal solution. – Deepak Danduprolu May 29 '11 at 21:32
  • i try to make an app that can know which UIButton was pressed or to get info when UIButton was pressed,and i dont want to give any UIButton a method or a method for all the UIButtons – yosifz8 May 29 '11 at 21:52
  • possible duplicate of [Is there a way to pass touches through on the iPhone?](http://stackoverflow.com/questions/631427/is-there-a-way-to-pass-touches-through-on-the-iphone) – brandonscript Sep 25 '15 at 21:34

1 Answers1

3

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

Community
  • 1
  • 1
Anton
  • 2,342
  • 15
  • 17
  • thx,the problem that when i use it the method that need to happen when the UIButton was press didn't happen – yosifz8 May 29 '11 at 21:53