NSTableView左上方的怪异矩形(NSBannerView) [英] Weird rectangle (NSBannerView) in left top of NSTableView

查看:53
本文介绍了NSTableView左上方的怪异矩形(NSBannerView)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用macOS应用程序,但遇到了一个奇怪的问题.在我的 NSTableView 的左上角(标题上方),显示了一个灰色矩形:

I'm working on an macOS app and I'm experiencing a weird issue. In the left top corner of my NSTableView (above the header), a grey rectangle is shown:

(我在NSTableView后面添加了一个NSBox,以使其在屏幕截图中更加清晰)

(I've added an NSBox behind the NSTableView to make it more clear in the screenshot)

借助Debug View层次结构,我已经看到它是一个NSBannerView,它已添加到包裹Table View的Scroll View中.

With the Debug View Hierarchy, I've seen it's an NSBannerView which is added to the Scroll View wrapping the Table View.

我的UI是使用Interface Builder(情节提要)构建的.我已经在Interface Builder中选中和取消选中了很多复选框,但是找不到它.Google和Stack Overflow也没有提供任何线索.谷歌搜索"NSBannerView"甚至只会产生一些macOS头文件.

My UI is built with Interface Builder (a storyboard). I've checked and unchecked lots of checkboxes in the Interface Builder but can't find what it is. Google and Stack Overflow also don't give any clues. Googling for "NSBannerView" even only yields some macOS header files.

如何摆脱矩形?

环境详细信息

  • macOS Mojave 10.14 Beta(18A365a)
  • Xcode 9.4.1(9F2000)

推荐答案

子类 NSTableRowView 并覆盖 layout ,在其中隐藏视图

Subclass NSTableRowView and overwrite layout, where you hide the view

- (void)layout {

    [super layout];

    for (NSView * v in self.subviews) {
        if ([v.className isEqual:@"NSBannerView"]) {
            v.hidden = YES;
        }
    }

}

这篇关于NSTableView左上方的怪异矩形(NSBannerView)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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