我有点卡住了,似乎无法从苹果文档中解决这个问题。NSTableView隐藏按钮
我在NSTable列中包含两个按钮,包含在NSTableCellView中。
我想在代码中隐藏该按钮取决于该行中对象的值。
获取值是好的,但我不能解决如何针对特定的按钮,我不能将它绑定到一个插座,因为它是在一个表内。我已经尝试了下面的代码,但这只是隐藏了整个NSTableCellView而不是特定的按钮,我也尝试将标识符更改为按钮,但似乎也这样做。
if(selectedTweet.imageURL){
NSButton *imageButton = [tableView makeViewWithIdentifier:@"secondButtons" owner:self];
[imageButton setHidden:NO];
return imageButton;
} else {
NSButton *imageButton = [tableView makeViewWithIdentifier:@"secondButtons" owner:self];
[imageButton setHidden:YES];
return imageButton;
}
这显然比我做它更简单?非常感谢。
感谢
加雷思
从你的代码我看到你正试图创建一个NSTableCellView的按钮可见/隐藏取决于条件。你试着在IB上有两个不同的预定义的NSTableCellView,如“secondButtonsWithButton”和“secondButtonsWithoutButton”,并调用每个必要时 ? – CoderPug