关于application title一直是untitled的问题
生活随笔
收集整理的這篇文章主要介紹了
关于application title一直是untitled的问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
建立了一個cocoa?application項目,在Interface Builder中修改了title,在運行時標題始終是“Untitled”。
這是我在http://stackoverflow.com/questions/4720030/cocoa-mac-application-title-says-untitled上找的解決方法。
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..
-> It will probably change to the name of your document once you save it (or open one). – zneak Jan 18 at 3:07
-> Naming a new, unsaved document “untitled” is the correct way according to the HIG.?http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGWindows/XHIGWindows.html#//apple_ref/doc/uid/20000961-CHDHBCGE?Why do you want to violate that convention? – Peter Hosey Jan 18 at 5:17
下面是比較暫時比較好的解決方法:覆蓋NSDocument的-displayName方法
One solution is to override -displayName in your NSDocument subclass:
- (NSString *)displayName {
????if (![self fileURL])
????????return @"Some custom untitled string";
????return [super displayName];
}
這是我在http://stackoverflow.com/questions/4720030/cocoa-mac-application-title-says-untitled上找的解決方法。
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..
-> It will probably change to the name of your document once you save it (or open one). – zneak Jan 18 at 3:07
-> Naming a new, unsaved document “untitled” is the correct way according to the HIG.?http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGWindows/XHIGWindows.html#//apple_ref/doc/uid/20000961-CHDHBCGE?Why do you want to violate that convention? – Peter Hosey Jan 18 at 5:17
下面是比較暫時比較好的解決方法:覆蓋NSDocument的-displayName方法
One solution is to override -displayName in your NSDocument subclass:
- (NSString *)displayName {
????if (![self fileURL])
????????return @"Some custom untitled string";
????return [super displayName];
}
You can also check out NSWindowController's -windowTitleForDocumentDisplayName: if you're using custom window controllers.
如果有好的建議,歡迎提供,多謝~
轉載于:https://www.cnblogs.com/aquariusgx/archive/2011/03/17/1986849.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的关于application title一直是untitled的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nginx:工作原理
- 下一篇: Office安装源损坏