【问题标题】:setTitleWithRepresentedFilename not changing NSWindows filename?setTitleWithRepresentedFilename 不更改 NSWindows 文件名?
【发布时间】:2017-05-10 15:40:18
【问题描述】:

我有一个NSDocument,我正在打电话:

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

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

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

但它仍然没有得到更新。

我已经确认self.windowForSheet 不为零。我做错了吗?请注意,我预计标题的“未命名 1”部分会发生变化。

【问题讨论】:

    标签: objective-c cocoa nswindow nsdocument


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-12
      • 1970-01-01
      • 1970-01-01
      • 2019-09-19
      • 1970-01-01
      相关资源
      最近更新 更多