我想垂直拖动此对象而不是水平拖动,现在就是这样做了:
- (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;
}
}
答案 0 :(得分:1)
CGPoint yLocation = CGPointMake(myObject.center.x, location.y);
myObject.center = yLocation;