奇怪的 XIB 文件问题

发布于 2024-12-14 04:41:11 字数 665 浏览 2 评论 0原文

在我编写的修改程序中遇到一个奇怪的问题。在我的第一次迭代中,视图控制器有一个标题为 userSpecifyingInput 的 IBAction,并将所有按钮都连接到该 IBAction。 为了使设计更加复杂,我引入了 userSpecifyingDigit 和 userSpecifyingLetter,并相应地将一些按钮连接到第一个 IBAction (userSpecifyingDigit),将下一个按钮连接到第二个 IBAction (userSpecifyingLetter)。 运行我的程序时,它给了我这个错误:

终止应用程序:NSInvalidArgumentException 发送到实例的无法识别的选择器

并且这些选择器在 userSpecifyingInput 和 userSpecifyingDigit 之间交替,这没有意义,因为 userSpecifyingInput 已从我的 ViewControllers 接口和实现中完全删除。

现在我不确定为什么 userSpecifyingInput 仍然存在,但在涉足发送事件之后,我注意到按钮已连接到新选择器和旧选择器。 我必须手动从所有按钮的 touchupinside 事件中删除旧的选择器。

当然,这似乎不是一种非常方便的处理方式,如果视图控制器选择器被修改,那么触摸事件应该被自动删除。

我在这里错过了什么吗?这是一个非常开放式的问题,有不同的答案

Experiencing a weird problem in a modified program written by me. In my first iteration, the view controller had an IBAction by the title userSpecifyingInput and had all my buttons wired up to this IBAction.
To make the design more sophisticated, I introduced userSpecifyingDigit and userSpecifyingLetter and accordingly had some buttons wiring up to the first IBAction (userSpecifyingDigit) and the next button wiring up to the second IBAction (userSpecifyingLetter).
Upon running my program, it gave me this error:

terminating app: NSInvalidArgumentException
Unrecognized selector sent to instance

And these selectors were alternating between userSpecifyingInput and userSpecifyingDigit which did not make sense as userSpecifyingInput was completely removed from my ViewControllers interface and implementations.

Now I am not sure why userSpecifyingInput still existed, but after dabbling with sent events, I noticed that the buttons were wired upto the new selectors as well as the old selector.
I had to manually remove the old selector from the touchupinside events for all the buttons.

Naturally this does not seem to be a very convenient way to go about proceedings and if the view controller selectors are modified then the touch events ought to be automatically removed.

Am I missing something here? This is a pretty open ended question with different answers

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

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

发布评论

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

评论(2

泅渡 2024-12-21 04:41:11

从您的实现中消除 IBAction 不会删除 IB 中任何先前指向它的链接。我还没有听说过任何 XCode/IB 首选项可以解决这个问题。

Eliminating an IBAction from your implementation will not remove any previous links to it in IB. I haven't heard of any XCode/IB preferences to shortcut this issue.

不爱素颜 2024-12-21 04:41:11

听起来 xib 仍然认为它的一个对象已连接到 UIViewController,但 UIViewController 上的功能不再存在。要检查并修复此问题...

  1. 单击项目导航器中的 xib 文件
  2. 选择文件的所有者
  3. 单击连接检查器
  4. 验证这些连接均无效

我还将查看 UIViewController 以确保此处不存在自动创建的引用以及。

Sounds like the xib still thinks one of it's objects is hooked up to the UIViewController, but the function on the UIViewController is no longer there. To check and fix this...

  1. Click on the xib file in the project navigator
  2. Select the File's Owner
  3. Click on the Connections Inspector
  4. Verify that none of these connections are invalid

I would also look in the UIViewController to make sure no automagically created references exist here as well.

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