NSTimer 具有触摸功能吗? 任何其他选项

发布于 2024-07-13 02:43:08 字数 354 浏览 6 评论 0原文

我正在创建我的第一个 iPhone 应用程序,在这里需要帮助。 我的编程背景不是 C,我有点迷失。

基本上我希望我的应用程序做的是显示随机位图并让用户触摸单个位图并验证它们。 我用来显示位图的方法是 NSTimer 和 UIImage 来显示实际位图。 到目前为止,它在显示位图方面工作正常。 但我陷入了下一步,即注册触摸的位图。 我尝试在位图上使用标签,然后使用 TouchBegan 函数。 每次触摸屏幕时都会出现运行时错误(我认为)。

我的问题是: 1. 根据我的要求,我使用的方法是一个好方法,或者在技术上可行吗? 2. 如果问题#1 的答案是否定的,您有其他解决方案吗?

谢谢并感谢您的帮助!

I am creating my very first iphone app and need help here. My programming background is not C and I am bit lost.

Basically what I want my application to do is to display random bitmaps and let user touch individual bitmap and validate them. The method I used to display the bitmaps is NSTimer with UIImage for the actual bitmaps. So far, it was working fine in displaying the bitmap. But I am stuck on the next step, which is registering the touched bitmaps. I tried to use tag on the bitmap then touchesBegan function. I got a runtime error everytime I touched screen (I think.)

My questions are:
1. Given my requirement, is the method I am using is a good method, or even technically possible?
2. If q#1 answer is no, do you have alternative solution?

Thanks and I appreciate your help!

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

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

发布评论

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

评论(1

倒数 2024-07-20 02:43:08

如果您在 touchesBegan: 函数中遇到异常,那么您的代码中存在错误。 如果您使用调试器运行应用程序,它应该准确地告诉您问题发生在哪一行代码上。 如果我不得不猜测,我会说您正在尝试将消息发送到不处理该消息的对象,这会引发异常。

确保您的代码在编译时没有任何警告——您可能在某个地方的函数名称中有拼写错误。 如果您拼写错误消息名称,它仍然可以正确编译,但当您尝试发送该消息时,它会在运行时抛出异常。

If you're getting an exception inside your touchesBegan: function, then your code there has a bug in it. If you run your app with the debugger, it should tell you on exactly what line of code the problem is occurring. If I had to guess, I would say that you're trying to send a message to an object which doesn't handle that message, which throws an exception.

Make sure your code is compiling without any warnings -- it's possible you have a typo in a function name somewhere. If you misspell the message name, it will still compile correctly, but it will throw an exception at runtime when you try to send that message.

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