0

I've created a UIButton and detect the touch event by:

[myButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];

Everything works fine when I press exactly on the button.
My problem is that if I press with my finger part on the button and part outside - The event is not detected.
Is there another event I should use?
Am I doing something wrong here?

I'm sure people will say that you have to press exactly in the button but I'm trying to give the best user experience and resolve this issue.
Thanks!

Code Monkey
  • 968
  • 1
  • 14
  • 26

1 Answers1

0

You may want to enlarge your button, making perhaps a transparent area around your image.

Or maybe use UIControlEventTouchDown/UIControlEventTouchUpOutside instead of UIControlEventTouchUpInside ?

PatrickNLT
  • 4,075
  • 1
  • 25
  • 32
  • If I'm enlarging the button - the highlighting I'm using will not mark the button area correctly. The events you suggested did not help... – Code Monkey Oct 09 '12 at 14:03
  • What kind of highlighting are you using? If you are using an image, make sure you are setting the image (not the background image) of your UIButton instance. – PatrickNLT Oct 09 '12 at 14:18
  • Anyway, if you are really trying to give the best user experience, just stick with the default behavior as this is the one that the users are used to (and use bigger buttons!). – PatrickNLT Oct 09 '12 at 14:20