Ios 触摸开始和触摸移动不';不行。如果陈述是错误的?
我卡住了。我有3个物体,我喜欢在屏幕上移动,但不在同一个地方。我的IF语句有什么问题?在Debug中,我总是在else语句中。谢谢你的帮助Ios 触摸开始和触摸移动不';不行。如果陈述是错误的?,ios,objective-c,touchesbegan,touchesmoved,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 ([touc
-(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");
}
}
触摸移动
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}
不应将对象与“==”进行比较。使用isEqual:代替。@rdelmar:我不认为这会对UIView对象产生影响。好的,谢谢!但它仍然不起作用……你确定himmel不是零吗?@rdelmar“himmel”是一个标签。