iPhone - 我已经更改了 XIB FileOwner,但它不断命中原始文件所有者中的方法
所以...
- 我有一个 HomeViewController 和一个 IBAction DoStuff。
我有一个 XIB,其文件所有者为 HomeViewController,其中包含 正确调用 DoStuff 的按钮;
然后创建一个 NewViewController,将 DoStuff 方法复制到其中。
- 在 XIB 中,我将文件所有者的类更新为 NewViewController,删除并重新添加按钮的操作 对于DoStuff。
但是...按钮仍在从 HomeViewController 调用 DoStuff。
还有其他地方我需要删除这个引用吗?
非常感谢,
R
So...
- I have a HomeViewController, with an IBAction DoStuff.
I have a XIB that has a File Owner of HomeViewController, which contains
button that correctly calls DoStuff;Then created a NewViewController, copying the DoStuff method into it.
- Within the XIB, I then updated the Class of the File Owner to
NewViewController, and deleted and re-added the action to the button
for DoStuff.
BUT... the button is still calling DoStuff from HomeViewController.
Is there somewhere else I need to remove this reference??
Thanks very much,
R
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定正在从正确的控制器加载 nib 文件吗?请注意,“文件所有者”只是 nib 文件中的占位符,它必须是在代码中创建的;除了文件所有者中的“类名”之外,IB 仅需要提供对其 IBAction 和 IBOutlet 的引用,但您需要确保在代码中正确加载它。
因此,如果在旧代码中您有类似的内容:
您必须将当前代码更改为:
在这种情况下,您将继续加载相同的 nib 文件,但所有对象都将被取消归档并分配给正确的文件所有者,即在代码。
请检查这一点,如果不起作用,请发布您的代码。
Are you sure you are loading the nib file from the right controller? note that "File's Owner" is just a placeholder in the nib file and it must have been created in code; besides the "class name" in File's Owner is only needed by IB to provide the references to its IBAction and IBOutlet but you need to ensure that you're loading it in code correctly.
So if in the old code you had something like:
you must change the current code as:
in this case you will keep loading the same nib file but all objects will be unarchived and assigned to the right file owner which is the one specified in the code.
Please check this point, if it's not working then post your code.