Access Photo Library via Objective-C/Xcode in iOS

无人久伴 提交于 2019-12-11 02:27:57

问题


I'm writing an iPhone application. I'm wondering if I can get a list of files/filenames of the photos stored in the iPhone library (or those in the simulator).

Essentially, I'm asking if I can get the filenames of the photos stored on the iPhone or simulator.

I appreciate any help, thanks!

EDIT:

image = [UIImage imageNamed:@"/Users/Library/Application Support/iPhone Simulator/5.0/Media/DCIM/100APPLE/IMG_0002.jpg"];
imageView.image = image;

doesn't work, unfortunately.


回答1:


You simply have to use the UIImagePickerController.

It gives something like that:

-(IBAction) getPhoto:(id) sender {
    UIImagePickerController * picker = [[UIImagePickerController alloc] init];

    // Don't forget to add UIImagePickerControllerDelegate in your .h
    picker.delegate = self;

    if((UIButton *) sender == choosePhotoBtn) {
        picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    } else {
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    }

    [self presentModalViewController:picker animated:YES];
}



回答2:


This is something of a duplicate of a SO question asked already here - Get list of all photo albums and thumbnails for each album

From that answer: Take a look at AssetsLibrary framework.

Note that if you have access to the iOS 6 Beta, you'll want to note the changes taking place for accessing those assets. Can say no more per NDA.




回答3:


Using this methods, you can easily implement that.

https://www.dropbox.com/sh/trmg44a93hwq35x/AACAVGY6VKEDR0tDUOqoxd-Ba?dl=0



来源:https://stackoverflow.com/questions/11319463/access-photo-library-via-objective-c-xcode-in-ios

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