tags:

views:

13

answers:

1

i like to drag this object vertically instead of horizontally, which is doin it now:

- (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;
    }
}
A: 
CGPoint yLocation = CGPointMake(myObject.center.x, location.y);
myObject.center = yLocation;
Marcelo Cantos
THANK YOU, THANK YOU, THANK YOU!!!
blacksheep
Don't thank me; just up-vote and accept the answer. ;-)
Marcelo Cantos
ok. but i got still a little problem: draging is workin outside the object with that code:- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view]; CGPoint xLocation = CGPointMake(location.x, myObject.center.y); myObject.center = xLocation;}but not with the code above.
blacksheep
Add this to the question. It's very difficult to read code in comments.
Marcelo Cantos
Ok, I figured it out. That's precisely what the `CGRectContainsPoint` test is supposed to do. It suppresses dragging when the touch is outside the object's frame.
Marcelo Cantos