我已经创建了一个基于文档的 Mac OSX 应用程序,当我在 Interface Builder 中编辑时,标题是正确的(我填写了检查器的那部分)但是程序运行后,应用程序标题是“无标题” .我该如何改变它?在我的 IB Doc 窗口中,我有 Files Owner、First Responder、NSApplication 和 NSWindow 的实例。没有 View Controller ,这是问题所在吗?我是 Cocoa 的新手..
最佳答案
一种解决方案是在您的 NSDocument
子类中覆盖 -displayName
:
- (NSString *)displayName {
if (![self fileURL])
return @"Some custom untitled string";
return [super displayName];
}
如果您使用的是自定义窗口 Controller ,您还可以查看 NSWindowController
的 -windowTitleForDocumentDisplayName:
。
关于objective-c - Cocoa Mac 应用程序标题为 : "untitled",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4720030/