可可Mac应用标题说:“无标题” [英] Cocoa Mac Application Title says: "untitled"

查看:103
本文介绍了可可Mac应用标题说:“无标题”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个基于文档的Mac OSX应用程序,当我在Interface Builder中编辑时,标题是正确的(我填写了检查员的那部分)但是一旦程序运行,应用程序标题就是无标题 。我该怎么改变它?在我的IB文档窗口中,我有文件所有者,第一响应者,NSApplication和NSWindow的实例。没有视图控制器,那是什么问题?我是Cocoa的新手..

I have created a document based Mac OSX application, and when I'm editing in Interface Builder, the title is correct (I filled out that portion of the inspector) but once the program runs, the application title is 'Untitled'. How can I change it? In my IB Doc Window, I have instances of Files Owner, First Responder, NSApplication, and NSWindow. There is no view controller, is that the issue? I'm new to Cocoa..

推荐答案

一种解决方案是覆盖 -displayName NSDocument 子类中:

One solution is to override -displayName in your NSDocument subclass:

- (NSString *)displayName {
    if (![self fileURL])
        return @"Some custom untitled string";

    return [super displayName];
}

您还可以查看 NSWindowController 's -windowTitleForDocumentDisplayName:如果您使用的是自定义窗口控制器。

You can also check out NSWindowController's -windowTitleForDocumentDisplayName: if you're using custom window controllers.

这篇关于可可Mac应用标题说:“无标题”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆