CGPoint 为 x 和 y 提供相同的值?

发布于 2024-12-29 09:03:07 字数 401 浏览 3 评论 0原文

这是我在旧 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兮子 2025-01-05 09:03:07

看来问题与 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文