如何在没有图标的情况下显示文档窗口的标题?

时间:2009-03-05 06:18:34

标签: cocoa

现在我将文件拖到停靠栏中的应用程序图标,此应用程序基于文档。我发现在应用程序运行并且主窗口打开后,窗口标题左侧没有小图像。但是当我在应用程序运行之前将文件拖到停靠栏图标并使用此方法运行应用程序时,窗口标题左侧的一个小图像显示文件,就像xcode等一样。 现在我想以两种方式显示小图像以显示小图像两种方式,怎么办?我认为它可能是基于文档的窗口属性,但我不知道如何解决它?谢谢!alt text http:///Users/jinxin/Desktop/Mydocument.png


我使用了[mainWindow setTitle:tmp];,但图标仍然显示。当我使用setTitleWithRepresentedFilename:时,我发现图标和窗口标题名都都是修改的,在文档类中我重载了-(void)displayName;所以我想随时修复窗口标题。

4 个答案:

答案 0 :(得分:2)

如果您只使用-setTitle:,则无图标。如果您使用-setTitleWithRepresentedFilename:,则会获得图标。

答案 1 :(得分:2)

好的,我找到了结果:

1

[[window standardWindowButton:NSWindowDocumentIconButton] setImage:image]

2

- (BOOL)window:(NSWindow *)sender shouldPopUpDocumentPathMenu:(NSMenu *)titleMenu
{
    return NO;
}

答案 2 :(得分:1)

来自NSWindow的Cocoa文档(在representedURL下):

[[window standardWindowButton:NSWindowDocumentIconButton] setImage:image]

将它设置为nil可以解决问题。

答案 3 :(得分:0)

我尝试了上面的所有答案,但它们没有用。这在小牛队中对我有用:

How to hide file icon in window titlebar of NSDocument