zoukankan      html  css  js  c++  java
  • 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//取消

    {

    }

  • 相关阅读:
    学习Oracle数据库入门到精通教程资料合集
    linux编程中printf显示不加换行的缓冲问题
    让 Terminal/vim 使用 Solarized 配色
    vim插件ctags的安装和使用
    rsync 同步文件
    try catch 场景
    关于浮点型的运算---比较
    mysql数据库死锁的产生原因及解决办法
    Laravel下载地址合集
    php垃圾回收机制
  • 原文地址:https://www.cnblogs.com/417460188dy/p/3907729.html
Copyright © 2011-2022 走看看