UIImagePickerController
2011-07-19 12:38
204 查看
UIImagePickerControllerUIImagePickerController:
1. 有三种工作模式:
//打开图片库根目录选择
UIImagePickerControllerSourceTypePhotoLibrary
//使用相机选择
UIImagePickerControllerSourceTypeCamera
//打开SavedPhoto目录选择
UIImagePickerControllerSourceTypeSavedPhotosAlbum
2. //用此方法可以判断,设备是否有拍照功能。
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//用模式窗体转换到图片选取界面。
UIImagePickerController *aImagePickerController = [[UIImagePickerController alloc] init];
aImagePickerController.delegate = self;
aImagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
BarStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.navController presentModalViewController:aImagePickerController animated:YES];
[aImagePickerController release];
}
3. //两个主要的委托方法
#pragma mark UIImagePickerController Delegate Methods
//返回选取的图片
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo {
aImageView.image=image;
[picker dismissModalViewControllerAnimated:YES];
}
//选取结束时调用
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissModalViewControllerAnimated:YES];
}
4. iPhone Simulator获取获取图片方法。
a. 使用safari,按住图片,选择保存;
b.(来自http://stackoverflow.com/questions/468879/adding-images-to-iphone-simulator)Go to ~/Library/Application Support/iPhone Simulator/User/Media/DCIM/100APPLE/ and add IMG_nnnn.THM and IMG_nnnn.JPG. It doesn't matter if they are not JPEGs - they can both be PNGs, but it appears that both of them must be present for it to work. You may need to create DCIM if it doesn't already exist, and in that case you should start nnnn from 0001. The JPG files are the fullsize version, while the THM files are the thumbnail, and are 75x75 pixels in size. I wrote a script to do this, but there's a better documented one over here.
You can also add photos from safari in the simulator, by Tapping and Holding on the image. If you drag an image (or any other file, like a PDF) to the simulator, it will immediately open Safari and display the image, so this is quite an easy way of getting images to it.
1. 有三种工作模式:
//打开图片库根目录选择
UIImagePickerControllerSourceTypePhotoLibrary
//使用相机选择
UIImagePickerControllerSourceTypeCamera
//打开SavedPhoto目录选择
UIImagePickerControllerSourceTypeSavedPhotosAlbum
2. //用此方法可以判断,设备是否有拍照功能。
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//用模式窗体转换到图片选取界面。
UIImagePickerController *aImagePickerController = [[UIImagePickerController alloc] init];
aImagePickerController.delegate = self;
aImagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
BarStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.navController presentModalViewController:aImagePickerController animated:YES];
[aImagePickerController release];
}
3. //两个主要的委托方法
#pragma mark UIImagePickerController Delegate Methods
//返回选取的图片
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo {
aImageView.image=image;
[picker dismissModalViewControllerAnimated:YES];
}
//选取结束时调用
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissModalViewControllerAnimated:YES];
}
4. iPhone Simulator获取获取图片方法。
a. 使用safari,按住图片,选择保存;
b.(来自http://stackoverflow.com/questions/468879/adding-images-to-iphone-simulator)Go to ~/Library/Application Support/iPhone Simulator/User/Media/DCIM/100APPLE/ and add IMG_nnnn.THM and IMG_nnnn.JPG. It doesn't matter if they are not JPEGs - they can both be PNGs, but it appears that both of them must be present for it to work. You may need to create DCIM if it doesn't already exist, and in that case you should start nnnn from 0001. The JPG files are the fullsize version, while the THM files are the thumbnail, and are 75x75 pixels in size. I wrote a script to do this, but there's a better documented one over here.
You can also add photos from safari in the simulator, by Tapping and Holding on the image. If you drag an image (or any other file, like a PDF) to the simulator, it will immediately open Safari and display the image, so this is quite an easy way of getting images to it.
相关文章推荐
- 修改UIImagePickerController拍照后旋转问题
- Status bar colour for UIImagePickerController
- UIImagePickerController  本地照片
- UIImagePickerController 图像选取器--在iPhone中调用照相机、照片库
- UIImagePickerController自动修改statusbar文字颜色
- UIImagePickerController 内存警告研究
- 设置应用内的系统控件语言 如UIImagePickerController
- iOS 自定义相机, UIImagePickerController && AVCaptureSession (附微信小视频模仿demo)
- UIImagePickerController 调用系统相机 相册
- UIImagePickerController的一些属性(调照相机或者图片)
- How to select Multiple images from UIImagePickerController [duplicate]
- UIImagePickerController 相册取照片
- iphone 怎么使用图片选取器 UIImagePickerController
- UIImagePickerController Save to Disk then Load to UIImageView
- UIImagePickerController本地图片视频,相机录像机使用
- 重定义 UIImagePickerController
- iOS使用UIImagePickerController
- 基于Swift的iOS应用程序开发:使用UIImagePickerController调取摄像头进行拍照
- iOS摄像头和相册-UIImagePickerController-浅析
- IOS UIImagePickerController从拍照、图库、相册获取图片