我有一个正在调用的 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/