作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我向用户展示 NSOpenPanel
时,我希望它从一开始就已经选择了用户之前打开的文件。
有[NSSavePanel setDirectoryURL:(NSURL*)
来预选目录,但我找不到API来选择初始文件。
曾经有:
- (NSInteger)runModalForDirectory:(NSString *)path file:(NSString *)filename
这个电话正是我所需要的。文档说:
Specifies a particular file in path that is selected when the Save panel is presented to a user. When nil, no file is initially selected.
但不幸的是,该方法在 10.6 中已被弃用。
最佳答案
执行这些 NSSavePanel 方法
- (void)setDirectoryURL:(NSURL *)url
- (void)setNameFieldStringValue:(NSString *)value
不做你想做的事?
NSOpenPanel 是 NSSavePanel 的子类,因此它也具有这些方法。
关于cocoa - NSOpenPanel/NSSavePanel : How can I preselect a file before the dialog opens?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8278490/
我是一名优秀的程序员,十分优秀!