1

enter image description here

  1. touch and hold button - start task and show slide-to-cancel slider
  2. end touch without sliding - finish task and remove slide-to-cancel slider
  3. start sliding to right without ending touch - cancel the task
  4. finish sliding and end touch - remove slide-to-cancel slider

I am thinking to add to transparent UIView on top and forward the touch event to the subview that is UIButton and UISlider with help of hitTest: withEvent function.

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
  CGPoint hitPoint = [underneathView convertPoint:point fromView:self];
    if ([underneathView pointInside:hitPoint withEvent:event]){
        NSLog(@"UnderneathView");
        return underneathView;
    }
    NSLog(@"not UnderneathView");
  return [super hitTest:point withEvent:event];
}

But i am not sure how to use it properly. Please provide me some example/tutorial or suggest me a right way to go.

Thanks

coder1087
  • 115
  • 1
  • 2
  • 9
  • 2
    Take a look at these controls: [MBSliderView](https://github.com/mattlawer/MBSliderView), [SlideToCancel](https://github.com/iosdeveloper/SlideToCancel). With a few modifications you can get similar control. – Amar Oct 31 '13 at 05:56
  • Thanks Amar for quick response. I already know how to create slidetocancel but the main problem is that i don't want to remove finger ( or end touch) in whole process. I want 1. touch and hold for activate the task, 2. in between task processing if you want to cancel the task just slide to right without removing your finger from screen (without ending touch) – coder1087 Oct 31 '13 at 06:11
  • When you expect user to slide, you are required to handle cases when user lifts the finger from the screen. Use case would be to cancel slide and reset the button to original position. Or you can assume certain distance covered after which even if the user lifts the finger you will move the slider to unlock/final position. I hope I am understanding your issue. – Amar Oct 31 '13 at 06:17
  • I think i can just use a UISlider instead of UIButton and UISlider and use the control event action of UISlider - UIControlEventTouchUpInside, UIControlEventTouchUpOutside, UIControlEventTouchDown and UIControlEventValueChanged. Not a perfect solution but would work for now. – coder1087 Oct 31 '13 at 06:30

0 Answers0