通过iOS中的Objective-C/Xcode访问照片库 [英] Access Photo Library via Objective-C/Xcode in iOS
本文介绍了通过iOS中的Objective-C/Xcode访问照片库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个iPhone应用程序.我想知道是否可以获取存储在iPhone库(或模拟器中)中的照片的文件名/文件名列表.
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).
本质上,我在问是否可以获取存储在iPhone或模拟器上的照片的文件名.
Essentially, I'm asking if I can get the filenames of the photos stored on the iPhone or simulator.
感谢您的帮助,谢谢!
image = [UIImage imageNamed:@"/Users/Library/Application Support/iPhone Simulator/5.0/Media/DCIM/100APPLE/IMG_0002.jpg"];
imageView.image = image;
不幸的是,它不起作用.
doesn't work, unfortunately.
推荐答案
您只需使用UIImagePickerController
.
它给出了类似的内容:
-(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];
}
这篇关于通过iOS中的Objective-C/Xcode访问照片库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文