2011-05-05 79 views
1

Touchesmoved沒有拿起我的光標位置。touchesMoved沒有註冊位置

我有這樣的代碼:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
    CGPoint touchPoint = [[touches anyObject] locationInView:svEditView]; 
    [((UIView *)[[svButtonsArray objectAtIndex:svTouchDownID] objectAtIndex:1]) setCenter:touchPoint]; 
    NSLog(@"Touches moved"); 
    NSLog(@"1. %i", touchPoint.x); 
    NSLog(@"2. %i", touchPoint.y); 
} 

所以它它告訴拖動並移動到正確的位置,但在它的NSLog每次都返回0,對於接觸點的UIView的。任何想法爲什麼?

編輯:改變它爲%f的作品,但它是一個完整的數字與一個大的尾數.000000結束,所以不知道爲什麼它不會與%我工作。

+0

你是否已經在根上的任何UIView子類中觸及了方法?主要是,svEditView? – 2011-05-05 18:42:17

回答

1

touchePoint.x和.y是float而不是int。您需要使用%f打印。

使用%f獲取的列表輸出。