gpt4 book ai didi

cocoa - NSTableView makeViewWithIdentifier 跨 Nib

转载 作者:行者123 更新时间:2023-12-03 16:06:27 24 4
gpt4 key购买 nike

我有一个类似的问题Cocoa - View-Based NSTableView, using one cell in multiple tables , 放大为 Apple's own docs对于 makeViewWithIdentifier:owner:

"Typically identifier is associated with an external NIB in Interface Builder and the table view will automatically instantiate the NIB with the provided owner."

这似乎意味着您应该能够将 NSTableCellView 存储在与包含 NSTableView 的 Nib 不同的 Nib 中。然而,在我的实验中,我只能获取我调用的表格 View 中包含的单元格。即,如果我将单元格剪切并粘贴到新的 .xib 文件中,表格 View 将无法再找到它。我做错了什么,或者这实际上是不可能的,我在某种程度上误读了苹果的文档?

最佳答案

使用 - (void)registerNib:(NSNIb *)nib forIdentifier:(NSString *)identifier 注册要与单元标识符一起使用的 Nib 。

如果它不起作用,您可能会在加载 tableView 数据后注册 Nib 。使用 [tableView reloadData] 后记来确保这不是时间问题。

关于cocoa - NSTableView makeViewWithIdentifier 跨 Nib ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10887670/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com