每当手指移动时,使用UIGestureRecognizer获取坐标?

时间:2014-08-22 05:04:07

标签: objective-c slider uigesturerecognizer jailbreak user-interaction

我正在尝试制作一个滑块,用手指从左到右滑动图像。我想使用UIGestureRecognizer。为了这个目的我该如何做到这一点,每次手指移动时都会记下手指的坐标?

1 个答案:

答案 0 :(得分:1)

您可以尝试这样的事情

-(void)viewDidLoad;
{
   [super viewDidLoad];
   UIPanGestureRecognizer* pgr = [[UIPanGestureRecognizer alloc] 
                                       initWithTarget:self
                                               action:@selector(handlePan:)];
   [self.panningView addGestureRecognizer:pgr];

}

-(void)handlePan:(UIPanGestureRecognizer*)pgr;
{
   if (pgr.state == UIGestureRecognizerStateChanged) {
      CGPoint center = pgr.view.center;
      imageView.center = center;

   }
}