如何在Mac OS X应用程序中直接从NSOpenPanel访问媒体部分(照片和电影)? [英] How to access Media section (Photo & Movies) directly from NSOpenPanel in Mac OS X application?
本文介绍了如何在Mac OS X应用程序中直接从NSOpenPanel访问媒体部分(照片和电影)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已指出这个连结
iMedia
现在我使用NSOpenPanel打开iPhoto库文件夹。
Now i am using NSOpenPanel to open iPhoto library folder.
以下是允许打开的代码。
Here is the code which allow to open.
int i = 0;
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseFiles:YES];
[openDlg setAllowedFileTypes:[NSArray arrayWithObjects:@"public.image",@"public.video",nil]];
[openDlg setAllowsMultipleSelection:TRUE];
[openDlg setAllowsOtherFileTypes:NO];
if ( [openDlg runModal] == NSOKButton )
{
NSArray *files = [openDlg URLs];
for( i = 0; i < [files count]; i++ )
{
NSLog(@"File path: %@", [[files objectAtIndex:i] path]);
}
}
此代码始终打开我的Finder库文件夹想直接打开Media Photo和Movies文件夹。
This code always open my Finder library folder, As i want to open Media Photo and Movies folder directly.
请给我任何解决方案。
Please give me any solution.
我在这里附上了一个屏幕截图。
I have attached here one screen shot.
谢谢&
推荐答案
您可以考虑添加以下代码snipet:
You may consider adding the following code snipet:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSURL *picturesURL = [fileManager URLForDirectory:NSPicturesDirectory inDomain:NSUserDomainMask appropriateForURL:NULL create:NO error:&error];
NSURL *iPhotoURL = [picturesURL URLByAppendingPathComponent:@"iPhoto Library.photolibrary"];
[openDlg setDirectoryURL:iPhotoURL];
// Now run the dialog
用户已将其iPhoto库移动到某个非标准位置。
This won't help if the user has moved his iPhoto library to some non-standard location.
这篇关于如何在Mac OS X应用程序中直接从NSOpenPanel访问媒体部分(照片和电影)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文