문제

The matter is, I'm making a drag and drop iPad game. Moving my view like that

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    CGPoint pt = [[touches anyObject] locationInView:self.superview];
    self.center = CGPointMake(pt.x - _xOffset, pt.y - _yOffset);
}

But in some moment I want to stop dragging my view and put it to some location. I'm stuck on how to do that.

도움이 되었습니까?

해결책

You could try to disable the touch handling when you go to position the view finally. Probably the easiest thing to do it to add an instance variable (like BOOL draggingEnabled) which you use to choose how to handle the user interaction. Set the flag to YES when you start a new touch and to NO when you move to the final position. Check the value in touchesMoved before you change the view center.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top