objective-c - setTitleWithRepresentedFilename 不更改 NSWindows 文件名?

标签 objective-c cocoa nswindow nsdocument

我有一个正在调用的 NSDocument:

[self.windowForSheet setTitleWithRepresentedFilename: @"hello"];

打开,但窗口标题不变。它显示 MyApp -- Untitled 1。我也尝试过:

[self.windowForSheet setTitleWithRepresentedFilename: @"hello"];
[self.windowForSheet display];

但仍然没有更新。

我已经确认 self.windowForSheet 不为零。我这样做错了吗?请注意,我预计标题的“Untitled 1”部分会发生更改。

最佳答案

setTitleWithRepresentedFilename使用filePath,而不是任意文本字符串;我想您可能正在寻找title也许。

如果@"hello"不是文件的实际路径,则将其与setTitleWithRepresentedFilename一起使用可能不会返回文件的名称,这在turn 不会改变窗口的标题。

关于objective-c - setTitleWithRepresentedFilename 不更改 NSWindows 文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43897138/

相关文章:

ios - 更改事件时区是否会影响共享事件中的其他人?

iphone - cocoa 中的小写 "k"

iphone - UITableViewController 在选择单元格时不突出显示单元格

Cocoa如何处理多个 View ?

cocoa - NSWindow 翻转动画 - 像 iWork

Ios- Ipad- UicollectionViewCell- 单元格上的图标- 如何在 xcode 5 中向图标添加点击手势?

c++ - 我应该为 memcpy 和 realloc 包含什么标题?

ios - 如何关闭自动手势以使用导航 Controller 返回 View ?

objective-c - NSViewController loadView 加载了 "(null)"nib 但没有设置 View

macos - 关闭一个小型化的 NSWindow 然后恢复它