Mah*_*hir 0 floating-point integer casting objective-c uitouch
我正在基于UITouch分配视图的中心.我读到UITouch返回一个int值 - 这意味着它没有给我确切的触摸位置.有没有办法投射触摸值,以便我得到接触点的未接地位置?
CGPoint touchPoint = [touch locationInView:self];
self.thumb.center = CGPointMake(touchPoint.x, touchPoint.y);
Run Code Online (Sandbox Code Playgroud)
你究竟在哪里读到UITouch返回一个int值?那是完全错的.您的代码已经证明它有多么错误,因为您已经知道UITouch返回一个CGPoint值.如果你看一下CGPoint它的定义,它由两个CGFloat字段组成,所以它已经是一个浮点值.