iOS UIScrollView with 2 finger pan for paging and one finger pan for "fingerpointer"
I spend quite some time to figure out how to achieve what I want to do but didn't find a proper solution for it, yet. I have a UIScrollView where I changed the panGestureRecognizer from one to two finger recognition so the paging only works when two fingers are used. Now I want to add an additional panGestureRecognizer that shows a courser if I'm panning with one finger. I tried that by just adding an additional panGestureRecognizer to the UIScrollView but then the app crashes immediately. So I thought of adding a subview that is transparent and positioned above the UIScrol开发者_JAVA技巧lView and that I delegate the two finger gestures to the UIScrollView with something like resgin firstResponder. I also thought of overwriting the pangestureRecognizer of the UIScrollView and let it add a Subview where my "fingerpointer"(a little point that is centered where I'm touching the screen right now) is located. I'm totally clueless what way I should go and how to implement it. Your help is greatly appreciated! Thanks a lot!
Timo
Ok, this is the second time editing my response. This might do the trick for you.
If you extend UIScrollView you can override these methods in this way:
//In your h file
BOOL cursorShown;
//In your m file
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
   if([touches count] == 1)
   {
      cursorShown = YES;
      CGPoint touchLocation = [[touches anyObject] locationInView:self.superview]
      //Add your cursor to the parent view here and set its location to touchLocation
   }
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{
   if(cursorShown == YES)
   {
      CGPoint touchLocation = [[touches anyObject] locationInView:self.superview]
      //Move your cursors location to touchLocation
   }
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{
   if(cursorShown == YES)
   {
      cursorShown = NO;
      //Destroy your cursor
   }
}
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event 
{
   if(cursorShown == YES)
   {
      cursorShown = NO;
      //Destroy your cursor
   }
}
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论