奇怪的 XIB 文件问题
在我编写的修改程序中遇到一个奇怪的问题。在我的第一次迭代中,视图控制器有一个标题为 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从您的实现中消除 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.
听起来 xib 仍然认为它的一个对象已连接到 UIViewController,但 UIViewController 上的功能不再存在。要检查并修复此问题...
我还将查看 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...
I would also look in the UIViewController to make sure no automagically created references exist here as well.