VLCHorizontalSwipeGestureRecognizer.m 874 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // VLCHorizontalSwipeGestureRecognizer.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 26.05.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. #import "VLCHorizontalSwipeGestureRecognizer.h"
  9. @interface VLCHorizontalSwipeGestureRecognizer ()
  10. {
  11. CGFloat _xOrigin;
  12. }
  13. @end
  14. @implementation VLCHorizontalSwipeGestureRecognizer
  15. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  16. {
  17. _xOrigin = [touches.anyObject locationInView:self.view].x;
  18. }
  19. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
  20. {
  21. CGFloat currentX = [touches.anyObject locationInView:self.view].x;
  22. CGFloat viewWidth = self.view.bounds.size.width;
  23. if ([self.delegate respondsToSelector:@selector(horizontalSwipePercentage:inView:)])
  24. [self.delegate horizontalSwipePercentage:(currentX - _xOrigin)/viewWidth inView:self.view];
  25. }
  26. @end