尝试实现触摸事件时的行为非常奇怪

发布于 2024-09-08 20:37:36 字数 355 浏览 6 评论 0原文

我正在开发我的第一个 iPhone 应用程序,当我尝试实现触摸事件时,我遇到了一些非常奇怪的行为。

我在 UIViewController 的子类下设置了 touchesBegan:withEvent: 及其姊妹方法,但它们没有注册。更奇怪的是,当我在运行控制台时尝试在模拟器上使用触摸时,控制台会记录我的触摸,即使我的程序中根本没有 NSLog 语句!有一次,我在 touchesBegan:withEvent: 等下设置了 NSLog 语句,但很快我就删除了它们。我不知道这些日志来自哪里。

这是响应者链的问题吗?为什么控制台的行为如此奇怪?有什么想法吗?

I'm working on my first iPhone application, and I'm getting some very strange behavior when I try to implement touch events.

I set up touchesBegan:withEvent: and its sister methods under a subclass of UIViewController, but they aren't registering. What's even weirder is that when I try using touches on the simulator while running the console, the console logs my touches, even though I have no NSLog statements in my program at all! At one point, I set up NSLog statements under touchesBegan:withEvent: etc., but I deleted them soon after. I have no idea where these logs are coming from.

Is this some issue with the responder chain? Why is the console behaving so weirdly? Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

云朵有点甜 2024-09-15 20:37:36

一点也不奇怪。视图控制器只是控制器,而不是视图。您需要在您的 UIView 子类中实现它们。

至于奇怪的控制台输出 - 也许干净的重建会有所帮助,或者我们需要一些代码来查看。

Not weird at all. View controllers are just controllers - not views. You need to implement them in your UIView subclasses.

As for the strange console output - maybe a clean rebuilt will help, or we need some code to look at.

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