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);
}因此,它被告知拖动的UIView确实移动到了正确的位置,但在NSLog上,对于touchPoint,它每次都返回0。你知道为什么吗?
编辑:将其更改为%f可以,但它是一个完整的数字,末尾有一大段.000000,所以不确定为什么它不能与%i一起使用。
发布于 2011-05-06 02:44:37
X和.y是浮点型,而不是整型。您需要使用%f进行打印。
列出使用%f获得的输出。
https://stackoverflow.com/questions/5902534
复制相似问题