iOS调用系统相机

   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调用系统相机,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。