尝试实现触摸事件时的行为非常奇怪
我正在开发我的第一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一点也不奇怪。视图控制器只是控制器,而不是视图。您需要在您的
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.