码迷,mamicode.com
首页 > 移动开发 > 详细

iOS调用系统相机

时间:2014-08-12 18:11:34      阅读:314      评论:0      收藏:0      [点我收藏+]

标签:style   os   io   for   ar   cti   res   type   

   if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])//判断相机是否可用,模拟器不可用相机。

     {

         UIImagePickerController *imagePickerController=[[UIImagePickerController alloc] init];

         imagePickerController.delegate = self;

         imagePickerController.allowsEditing = YES; //是否允许重拍

         imagePickerController.sourceType=UIImagePickerControllerSourceTypeCamera; //

UIImagePickerControllerSourceTypePhotoLibrary打开相册

         imagePickerController.modalTransitionStyle=UIModalTransitionStyleCoverVertical;

         [self presentViewController:imagePickerController animated:YES completion:nil];

         return;

     }

 

#pragma mark - UIImagePickerControllerDelegate

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo NS_DEPRECATED_IOS(2_0, 3_0)

UIImagePickerControllerSourceTypePhotoLibrary//相册选取照片完成

{

}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

UIImagePickerControllerSourceTypePhotoLibrary//拍摄照片完成

{

    //得到图片

    UIImage * image = [info objectForKey:UIImagePickerControllerOriginalImage];

    //图片存入相册

    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker//取消

{

}

iOS调用系统相机,布布扣,bubuko.com

iOS调用系统相机

标签:style   os   io   for   ar   cti   res   type   

原文地址:http://www.cnblogs.com/417460188dy/p/3907729.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!