gpt4 book ai didi

cocoa - NSOpenPanel/NSSavePanel : How can I preselect a file before the dialog opens?

转载 作者:行者123 更新时间:2023-12-03 17:15:27 24 4
gpt4 key购买 nike

当我向用户展示 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com