[英]iOS camera capture view already?
I want a camera view that will capture a image to a local file or let user select an image fro m the local photo gallery. 我想要一个可以将图像捕获到本地文件或让用户从本地相册中选择图像的相机视图。 I think maybe someone has written good library/code for that.
我认为也许有人为此编写了不错的库/代码。 Maybe I can leverage it.
也许我可以利用它。 Is there any good one already?
已经有好东西了吗? Thanks.
谢谢。 I am just avoiding to reinvent the wheel :)
我只是在避免重新发明轮子:)
UIImagePickerController is built into iOS and very easy to use, it allows for all the functionally you want. UIImagePickerController内置于iOS中,非常易于使用,它可以满足您所需的所有功能。
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
For the user to take a new photo: 供用户拍摄新照片:
" UIImagePicker *imagePicker
" “
UIImagePicker *imagePicker
”
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == YES)
{
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.allowsEditing = NO;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
imagePicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:imagePicker animated:YES];
}
Or to choose an existing photo from the device: 或从设备中选择现有照片:
if( ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum] ) return;
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];
Be sure to include this! 一定要包括这个!
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[self dismissModalViewControllerAnimated:YES];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.