objective-c - Cocoa Mac 应用程序标题为 : "untitled"

标签 objective-c cocoa xcode macos interface-builder

我已经创建了一个基于文档的 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/

相关文章:

ios - Sprite Kit - 为多个场景定义变量

cocoa - 如何在 Cocoa 中调整带有显示三角形的额外框的大小?

快速错误 : 'EnumName' has a raw type that depends on itself

ios - XCUITest - 任务终止应用程序

objective-c - 如何在 NSOperation 中实现 NSRunLoop

iphone - UITableView Cell - 从按钮获取 IndexPath.row?

ios - MMDrawerController触摸UISlider应用于iOS 7上的错误 View

objective-c - 禁用 NSView 的淡入淡出动画 `setHidden:`

macos - 使用 swift 为 NSTextView 设置默认字体

ios - Xcode 12 中的 “Cannot preview in this file - Connection interrupted: send previewInstances message to agent"错误