简体   繁体   English

可可重命名MyDocument窗口标题

[英]Cocoa renaming MyDocument window title

How can I change the title of a window in a document based cocoa application? 如何在基于文档的可可应用程序中更改窗口的标题? I get an error when I try the following code in MyDocument.m 在MyDocument.m中尝试以下代码时出现错误

- (void)awakeFromNib
{
    [self setTitle:@"Document 1"];
}

Override displayName and return the value you want displayed. 覆盖displayName并返回要显示的值。

- (NSString *)displayName {
    return @"Document 1";
}

If you're subclassing NSWindowController then override windowTitleForDocumentDisplayName: instead. 如果要子类化NSWindowController windowTitleForDocumentDisplayName:改写windowTitleForDocumentDisplayName:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM