0

我成功地编写了一个可拖动的图像,但是,如果你随机点击屏幕上的某个地方,它只会将自己传送到那个点。我不想要那个!当您的手指在图像上时,如何使图像仅可拖动?这是我的代码:

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    symbol1.center = location;
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [self touchesBegan:touches withEvent:event];
}
4

0 回答 0