2009-03-05 84 views
1

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


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

回答

1

从可可文档的NSWindowrepresentedURL下):

[[window standardWindowButton:NSWindowDocumentIconButton] setImage:image] 

也许它设置为nil,会做的伎俩。

2

如果你只是使用-setTitle:,没有图标。如果您使用-setTitleWithRepresentedFilename:,您会看到图标。

2

OK,我发现结果:

1.

[[window standardWindowButton:NSWindowDocumentIconButton] setImage:image] 

2.

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