具有IBAction的按钮导致“无法连接动作,目标类NSNibExternalObjectPlaceholder不响应-action”。错误 [英] Button with IBAction causes "Could not connect action, target class NSNibExternalObjectPlaceholder does not respond to -action" error

查看:144
本文介绍了具有IBAction的按钮导致“无法连接动作,目标类NSNibExternalObjectPlaceholder不响应-action”。错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Storyboard场景,其中包含带有NSTableViewRow子类的NSTableView。在此表视图行中,我有一个按钮,已将其连接到场景中视图控制器中的一个动作。

I have a Storyboard scene which contains an NSTableView with an NSTableViewRow subclass. In this table view row, I have a button which I have wired up to an action in the view controller on the scene.

当表加载时,我看到了Xcode中的隐式错误,当我单击按钮时,操作永远不会触发:

When the table loads, I am seeing this cryptic error from Xcode and the action never fires when I click the button:

Could not connect action, target class NSNibExternalObjectPlaceholder does not respond to -playVideo:

文件所有者似乎从来没有连接过。

It looks like the file's owner never gets wired up.

由于以编程方式实例化了这些NSTableRowViews,因此我检查了所有者是否已被设置,并且确实是:

Since these NSTableRowViews get instantiated programmatically, I checked to see if the owner is getting set, and indeed it is:

- (NSView *) tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
...
CombinedHistoryEntryTableCellView *cellView = [tableView makeViewWithIdentifier:@"deviceEvent" owner:self];
...
return cellView;
}


推荐答案

我认为我遇到了错误(稍后我将提交雷达报告),但是我能够通过将按钮连接到IB中的 CombinedHistoryEntryTableCellView 类的操作来解决此问题。由于运行该动作所需的代码在视图控制器中,因此我为单元格视图对象提供了对该控制器的引用,以便可以对其进行调用。

I believe I am experiencing a bug (and I will file a radar later) but I was able to work around the issue by wiring the button up to an action on the CombinedHistoryEntryTableCellView class in IB. Since the code needed to run the action was in the view controller I gave the cell view object a reference to the controller so that it could call it.

虽然还是不知道为什么会这样,但是如果有人遇到这种情况,这是一个合适的解决方法。

Still don't know why that was an issue, though, but if someone else experiences this that is a suitable workaround.

这篇关于具有IBAction的按钮导致“无法连接动作,目标类NSNibExternalObjectPlaceholder不响应-action”。错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆