objective-c – 显示文件选择器对话框

前端之家收集整理的这篇文章主要介绍了objective-c – 显示文件选择器对话框前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在Mac OS X上显示文件选择器对话框?语言是Objective C.

解决方法

搜索的是“NSOpenPanel”,这里有一个例子如何使用:
  1. NSOpenPanel *panel = [NSOpenPanel openPanel];
  2. [panel setCanChooseFiles:NO];
  3. [panel setCanChooseDirectories:YES];
  4. [panel setAllowsMultipleSelection:YES]; // yes if more than one dir is allowed
  5.  
  6. NSInteger clicked = [panel runModal];
  7.  
  8. if (clicked == NSFileHandlingPanelOKButton) {
  9. for (NSURL *url in [panel URLs]) {
  10. // do something with the url here.
  11. }
  12. }

猜你在找的C&C++相关文章