【问题标题】:NSImageCell: Set ToolTipNSImageCell:设置工具提示
【发布时间】:2011-06-28 22:19:48
【问题描述】:

我试图在鼠标悬停在 NSImageCell 时显示工具提示。我已经尝试在 Interface Builder 上设置属性(在 NSImageCell 和包含它的 NSTableColumn 上),但它不起作用。

有什么想法吗?

【问题讨论】:

    标签: objective-c cocoa nstableview nsoutlineview nsimagecell


    【解决方案1】:

    NSCellNSTableColumn 都不会显示工具提示,因为它们都不是 NSView 的子类。您必须在表格视图本身上设置工具提示。

    您可以使用-[NSView addToolTipRect:owner:userData:] 为视图的特定区域设置工具提示。结合-[NSTableView frameOfCellAtColumn:row:],您应该能够为每个单元格设置一个不同的单元格。

    【讨论】:

      【解决方案2】:

      我通过在控制器中为我的 NSOutlineView 覆盖这个方法解决了这个问题:

      - (NSString *)outlineView:(NSOutlineView *)outlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn item:(id)item mouseLocation:(NSPoint)mouseLocation;
      

      【讨论】:

        【解决方案3】:

        如果是NSTableView,您可以使用

        (NSString *)tableView:(NSTableView *)tableView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation;
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-09-14
          • 1970-01-01
          • 2012-12-11
          • 1970-01-01
          • 2011-02-13
          • 1970-01-01
          • 2021-02-08
          • 1970-01-01
          相关资源
          最近更新 更多