我有一個在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