zoukankan      html  css  js  c++  java
  • iOS之UIImagePickerController的应用

    直接代码敬之

    @import MobileCoreServices;

    @import AVFoundation;

    <UIImagePickerControllerDelegate,UINavigationControllerDelegate>

    get方法

    - (UIImagePickerController*)imagePicker{

        if (!_imagePicker) {

        _imagePicker = [[UIImagePickerController alloc]init];

        //_imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

        _imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

        _imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;//摄像头分前后

            

            _imagePicker.allowsEditing= NO;

            //_imagePicker.allowsImageEditing = YES;

            

            UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];

            [button setBackgroundColor:[UIColor yellowColor]];

            [button setFrame:CGRectMake(80, 580, 50, 50)];

            button.layer.cornerRadius = 25.0;

            [_imagePicker.cameraOverlayView addSubview:button];

            

            _imagePicker.showsCameraControls = NO;

           // _imagePicker.cameraViewTransform = CGAffineTransformMakeRotation(M_PI_2);

            _imagePicker.delegate = self;

        }

        

        return _imagePicker;

    }

    事件响应实现跳转:注意貌似不能在viewdidload中操作

     [self presentViewController:self.imagePicker animated:YES completion:nil];

    #pragma   - mark    UIImagePickerControllerDelegate

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {

        NSLog(@"%s",__func__);

    }

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

        UIImage *image = [[UIImage alloc]init];

        if (self.imagePicker.allowsEditing) {

            image = [info objectForKey:UIImagePickerControllerEditedImage];

        }else{

            image = [info objectForKey:UIImagePickerControllerOriginalImage];

        }

        _img.image = image;

        [self.imagePicker dismissViewControllerAnimated:YES completion:nil];

         NSLog(@"%s",__func__);

    }

    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{

       [self dismissViewControllerAnimated:YES completion:nil];

        NSLog(@"cancel");

    }

    提高技能如同提升自信心。
  • 相关阅读:
    java web 入门实例servlet篇(显示后台数据库列表,删除某一条记录并显示)
    我的成长比价系列:java web开发过程中遇到的错误一:sql语句换行错误
    spring mvc + velocity 搭建实例程序maven版本并且使用的是tomcat容器而不是jetty(step by step)
    spring mvc学习笔记(一)web.xml文件配置的一点重要信息
    与数据库连接的页面增删改查 的easyui实现(主要是前端实现)
    oracle 11g 空表导出
    EMCA和EMCTL的简单用法
    vs2010补丁
    CAS 策略已被 .NET Framework 弃用
    sqlserver2008 链接服务器 2000
  • 原文地址:https://www.cnblogs.com/chims-liu-touch/p/5319543.html
Copyright © 2011-2022 走看看