【发布时间】:2014-08-18 17:52:08
【问题描述】:
在我当前的目标 C 项目中,我正在编写一种机制,当您在屏幕的一半上拖动手时,一个对象直接相关地移动,而当您在屏幕的另一半上拖动时,另一个对象直接移动相关性,但第一个没有。当我测试我的项目时,第一个对象在半屏上完美移动,但是当触摸另一半屏幕时第二个对象没有
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (location.x <= 259 )
[Person setCenter:CGPointMake(location.x, Person.center.y)];
if (location.y >289)
[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 <= 259 )
[Person setCenter:CGPointMake(location.x, Person.center.y)];
if (location.y >289)
[Person1 setCenter:CGPointMake(location.x, Person1.center.y)];
}
【问题讨论】:
-
您确实意识到用于决定要移动哪个对象的坐标系不是“屏幕的一半”,不是吗?
标签: ios objective-c uitouch