Selecting iPhoto images within a cocoa application
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 se开发者_如何学Clection of one picture at a time. I'd like a user to be able to select 1 picture, or many.
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.
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.
精彩评论