Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c NSOutlineView子类中内容更改时的通知 我想在没有内容的情况下,将NSutoLeVIEW子类显示在自己中间的一个标签中。与XCode中的检查器非常相似:_Objective C_Xcode_Cocoa_Nstableview_Nsoutlineview - Fatal编程技术网

Objective c NSOutlineView子类中内容更改时的通知 我想在没有内容的情况下,将NSutoLeVIEW子类显示在自己中间的一个标签中。与XCode中的检查器非常相似:

Objective c NSOutlineView子类中内容更改时的通知 我想在没有内容的情况下,将NSutoLeVIEW子类显示在自己中间的一个标签中。与XCode中的检查器非常相似:,objective-c,xcode,cocoa,nstableview,nsoutlineview,Objective C,Xcode,Cocoa,Nstableview,Nsoutlineview,显然,我不能使用委托方法,因为我将它实现为一个子类,并且在使用这个类时,我必须能够将委托设置为其他对象 除了bounds属性中的更改外,我没有发现任何可以观察到的通知,但这不是很可靠。我最终覆盖了NSOutlineView的几个方法来注入代码。这不是一个非常优雅的解决方案,但它很有效。如果有人有更好的解决方案,请告诉我,我可能会接受你的答案 - (void)updateEmptyLabelVisibility { int r = [[self dataSource] outlineVie

显然,我不能使用委托方法,因为我将它实现为一个子类,并且在使用这个类时,我必须能够将委托设置为其他对象


除了bounds属性中的更改外,我没有发现任何可以观察到的通知,但这不是很可靠。

我最终覆盖了
NSOutlineView
的几个方法来注入代码。这不是一个非常优雅的解决方案,但它很有效。如果有人有更好的解决方案,请告诉我,我可能会接受你的答案

- (void)updateEmptyLabelVisibility {
    int r = [[self dataSource] outlineView:self numberOfChildrenOfItem:nil];
    BOOL hasRows = r > 0;
    _emptyLabel.hidden = hasRows;
}

- (void)reloadItem:(id)item {
    [super reloadItem:item];
    [self updateEmptyLabelVisibility];
}

- (void)reloadData {
    [super reloadData];
    [self updateEmptyLabelVisibility];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self updateEmptyLabelVisibility];
}

- (void)endUpdates {
    [super endUpdates];
    [self updateEmptyLabelVisibility];
}