我花了很多时间来弄清楚如何实现我想做的事情,但却找不到合适的解决方案。我有一个UIScrollView,我将panGestureRecognizer从一个手指识别到两个手指识别,因此只有在使用两个手指时才能进行分页。现在我想添加一个额外的panGestureRecognizer,如果我用一根手指平移,它会显示一个courser。我尝试通过向UIScrollView添加额外的panGestureRecognizer但随后应用程序立即崩溃。所以我想添加一个透明且位于UIScrollView上方的子视图,并且我将两个手指手势委托给UIScrollView,例如resgin firstResponder。我还想过覆盖UIScrollView的pangestureRecognizer并让它添加一个Subview,其中我的“fingerpointer”(一个位于我正在触摸屏幕的中心位置的小点)位于其中。我完全无能为力,以及如何实现它。非常感谢您的帮助!非常感谢!
蒂莫
答案 0 :(得分:0)
好的,这是第二次编辑我的回复。这可能适合你。
如果扩展UIScrollView,可以用这种方式覆盖这些方法:
//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
}
}