我有一个在iPhone SDK中拖动对象的问题,我的UIImageView插座是红色的,我不知道为什么拖动不起作用!但是,当删除,如果行我的代码工作正常,这里是代码:拖动特定的对象
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches]anyObject];
if ([touch view] == red) {
CGPoint location = [touch locationInView:self.view];
red.center = location;
}
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}
您必须在CGTRE“touchesMoved”上写下您的对象的位置 – Momi 2010-12-02 12:23:27