Button with IBAction causes “Could not connect act

2019-09-11 12:49发布

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.

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.

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;
}

1条回答
Summer. ? 凉城
2楼-- · 2019-09-11 13:23

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.

查看更多
登录 后发表回答