【发布时间】:2014-09-28 19:40:25
【问题描述】:
在我当前的 ios 项目中,我将屏幕的一侧专用于一个对象,将屏幕的另一侧专用于另一个对象,我已经做到了,如果您在屏幕的一侧滑动手指指定的对象会移动。但是,我想这样做,以便您可以同时以不同的运动移动两个对象,但我不知道该怎么做。以下是我当前的代码。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (location.x <= 270 ) {
[Person setCenter:CGPointMake(location.x, Person.center.y)];
}
else {
[Person1 setCenter:CGPointMake(location.x, Person1.center.y)];
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (location.x <= 270 ) {
[Person setCenter:CGPointMake(location.x, Person.center.y)];
}
else {
[Person1 setCenter:CGPointMake(location.x, Person1.center.y)];
}
}
【问题讨论】:
标签: ios objective-c cocoa-touch uitouch