1

I have this custom element in an UITableViewCell and it is made from an image with 4 buttons over it. https://i.stack.imgur.com/e1CVK.jpg

Right now I am handling the selection with the TouchUpInside action on the button, but I want the user to be able to slide over it with a touch so it feels like you pickup the "slider" and then move it from ++ to - for example.
This means that I want to catch what button the user is currently sliding over to give that UIButton the selected state.

I've tried using the touchBegan method from: How to create buttons which are activated when the user slides their finger over them on iPhone. But UITouch always seems to be nil.
Am I doing it wrong or am I forgetting something?

Do you guys have any tips on how to implement this behaviour?

Thanks in advance!

Edit:
I ended up using a pan, tap and longpress -gesture recognizer.
Along with touchesbegan and touches ended.
This works really well and I do recommend it to everyone who is struggling with a similar issue!

Community
  • 1
  • 1
  • Have you tried using the "Touch Drag Enter" Action ? there are a whole load of them that might work.. [Look at the Apple Docs](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIControl_Class/Reference/Reference.html#jumpTo_24) – Wez Dec 02 '13 at 15:10
  • I have just tried it with calling this method: [self deselectButtons]; ((UIButton*)sender).selected = YES; But the UI doesn't update untill I "touch up" and then the button gets selected where I started. –  Dec 02 '13 at 15:27

1 Answers1

0

For your purpose not enough of using the method - (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event When the user moves the finger on the screen -(void)touchesMove:(NSSet *)touches withEvent:(UIEvent *)event method is called. Try use both methods for detect touch location.

Ruslan Soldatenko
  • 1,718
  • 17
  • 25