touchesBegan和TouchesMoved不起作用。如果声明错了?

时间:2014-04-18 16:09:28

标签: ios objective-c touchesbegan touchesmoved

我被困了。我有3个物体,我喜欢在屏幕上移动,但不是在同一个地方。我的IF声明有什么问题?在Debug中,我总是在else语句中。谢谢你的帮助!

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{


UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];

if ([touch view] == himmel) {
    himmel.center = location;
} else if ([touch view] == hoelle) {
    hoelle.center = location;
}
else if ([touch view] == regel) {
    regel.center = location;
}
else {
    NSLog(@"FAIL");
}

}

TouchesMoved

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

[self touchesBegan:touches withEvent:event];

}

0 个答案:

没有答案