仅当手指在UIImage上时才拖动UIImage

时间:2013-09-09 20:12:33

标签: ios objective-c drag-and-drop touch draggable

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

-(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];
}

0 个答案:

没有答案