垂直拖动对象

时间:2010-05-08 11:30:26

标签: iphone drag

我想垂直拖动此对象而不是水平拖动,现在就是这样做了:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    if (CGRectContainsPoint(myObject.frame, location)){
    CGPoint xLocation = CGPointMake(location.x, myObject.center.y);
    myObject.center = xLocation;
    }
}

1 个答案:

答案 0 :(得分:1)

CGPoint yLocation = CGPointMake(myObject.center.x, location.y);
myObject.center = yLocation;