Selecting iPhoto images within a cocoa application

﹥>﹥吖頭↗ 提交于 2019-12-05 07:14:33

问题


I was wondering what the best way of selecting photos from iPhoto within a cocoa application? Right now, the open file dialogue doesn't allow me to go into the iPhoto library. How can I allow the user to go into that folder? IKPictureTaker was one option, but it appears that it allows the selection of one picture at a time. I'd like a user to be able to select 1 picture, or many.


回答1:


Just use NSOpenPanel and set the allowed file types to the public.image UTI:

[panel setAllowedFileTypes:[NSArray arrayWithObject:@"public.image"]];

This will automatically add a Media section and Photos item to the sidebar in the open panel that allows the user to select from their iPhoto library.

Alternatively, you can use Karelia's open-source iMedia Browser.




回答2:


There is a private API of Apple that contains exactly the control you want; this control is an ILMediaBrowserView and provides the exact same view than the one in NSOpenDialog.

If you are planning an AppStore release of your app don't use it but it can be useful.

The framework to integrate to your project to get that view is iLifeMediaBrowser.framework in /System/Library/PrivateFrameworks.

Let's all hope Apple brings the same view in the documented IK.



来源:https://stackoverflow.com/questions/7423113/selecting-iphoto-images-within-a-cocoa-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!