我已經refered此鏈接如何在Mac OS X應用程序中直接從NSOpenPanel訪問媒體部分(照片和電影)?
我現在用的NSOpenPanel打開iPhoto圖庫文件夾。
這裏是允許打開的代碼。
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庫文件夾,因爲我想直接打開媒體照片和電影文件夾。
請給我任何解決方案。
我在這裏附上了一個截圖。
感謝&問候,
您的代碼正在工作,非常感謝。但我無法點擊視頻。任何其他額外的東西所需的? – 2013-04-05 03:04:44
現在完成了哥們,我只是改變了allowFileType到@「public.video」替換@「public.movie」並且工作.. – 2013-04-05 03:10:36
嗨jaggie_Gamer!我想用openPanel做一個快速測試,答案aLevelOfIndirection回答了你,但我沒有像你這樣的結果;我的openPanel顯示了iPhoto Library軟件包的內容。你有沒有在openPanel上添加任何選項,比如setCanChooseDirectories或setTreatsFilePackagesAsDirectories;將兩個設置爲NO。 – thebenjiman 2013-04-29 09:45:48