CGPoint 为 x 和 y 提供相同的值?
这是我在旧 iPod 上测试时遇到的一个奇怪的错误。我试图获取 TouchMoved 上的位置值,但 y 始终输出等于 x 的值。如果我使用 NSStringFromCGPoint 进行记录,那么我会得到正确的输出。为什么单独访问 x 和 y 不起作用?
CGPoint location = [singleTouch locationInView:self.view];
NSLog(@"Location using NSStringFromCGPoint %@", NSStringFromCGPoint(location)); // output: {27, 136}
NSLog(@"Location using x and y %f %f",location.x, location.y); // output: 27, 27
This is a strange bug I'm experiencing when testing on an old iPod. I'm trying to get location values on touchesMoved, but the y always outputs value equal to x. If I log using NSStringFromCGPoint, then I get the correct output. How come accessing x and y separately is not working?
CGPoint location = [singleTouch locationInView:self.view];
NSLog(@"Location using NSStringFromCGPoint %@", NSStringFromCGPoint(location)); // output: {27, 136}
NSLog(@"Location using x and y %f %f",location.x, location.y); // output: 27, 27
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来问题与 CGPoint 没有任何关系,而是与 plist 参数有关。
这个问题解决了我的问题。
It appears the problem didn't haven't anything to do with CGPoint but rather with the plist parameters.
This question solved my issue.