调用系统相机和相册 (iPad,iPhone)
打开相机:(iPad,iPhone)
//先设定sourceType为相机,然后判断相机是否可用(ipod)没相机,不可用将sourceType设定为相片库  
    UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;  
//    if (![UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {  
//        sourceType = UIImagePickerControllerSourceTypePhotoLibrary;  
//    }  
    //sourceType = UIImagePickerControllerSourceTypeCamera; //照相机  
    //sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //图片库  
    //sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; //保存的相片  
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];//初始化  
    picker.delegate = self;  
    picker.allowsEditing = YES;//设置可编辑  
    picker.sourceType = sourceType;  
    [self presentModalViewController:picker animated:YES];//进入照相界面  
    [picker release];

打开相册:(区分pad和iphone)for iphone:
UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];  
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {  
        pickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;  
        //pickerImage.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;  
        pickerImage.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:pickerImage.sourceType];  
          
    }  
    pickerImage.delegate = self;  
    pickerImage.allowsEditing = NO;  
    [self presentModalViewController:pickerImage animated:YES];  
    [pickerImage release];

打开相册for ipad:
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary;  
    //sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; //保存的相片  
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];  
    picker.delegate = self;  
    picker.allowsEditing = NO;//是否允许编辑  
    picker.sourceType = sourceType;  
    /* 
     如果从一个导航按钮处呈现,使用: 
     presentPopoverFromBarButtonItem:permittedArrowDirections:animated:; 
     如果要从一个视图出呈现,使用: 
     presentPopoverFromRect:inView:permittedArrowDirections:animated: 
      
     如果设备旋转以后,位置定位错误需要在父视图控制器的下面方法里面重新定位: 
     didRotateFromInterfaceOrientation:(在这个方法体里面重新设置rect) 
     然后再次调用: 
     - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated              
     */  
    //UIPopoverController只能在ipad设备上面使用;作用是用于显示临时内容,特点是总是显示在当前视图最前端,当单击界面的其他地方时自动消失。  
    UIPopoverController *popover = [[UIPopoverController alloc]initWithContentViewController:picker];  
    self.imagePicker = popover;  
    //permittedArrowDirections 设置箭头方向  
    [self.imagePicker presentPopoverFromRect:CGRectMake(0, 0, 300, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];  
    [picker release];  
    [popover release];

点击相册中的图片 货照相机照完后点击use
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

点击cancel 调用的方法
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

注意:需要添加@property (nonatomic, retain) UIPopoverController *imagePicker;

iOS开发 调用系统相机和相册的更多相关文章

  1. iOS开发 调用系统相机和相册 分类: ios技术 2015-03-30 15:52 65人阅读 评论(0) 收藏

     调用系统相机和相册 (iPad,iPhone) 打开相机:(iPad,iPhone) //先设定sourceType为相机,然后判断相机是否可用(ipod)没相机,不可用将sourceType设定为 ...

  2. Android调用系统相机和相册并解决data为空,OOM,图片角度不对的问题

    最近公司项目用到手机拍照的问题,好不容易在网上copy了一些代码,但是运行起来一大堆bug,先是三星手机上运行程序直接崩掉,debug了一下原来是onActivityResult中data返回为空,找 ...

  3. ios开发-调用系统自带手势

    在 iPhone 或 iPad 的开发中,除了用 touchesBegan / touchesMoved / touchesEnded 这组方法来控制使用者的手指触控外,也可以用 UIGestureR ...

  4. ios开发之--从相机或相册选取图片,并带删除操作的demo

    多选图片的一个效果,如下图:

  5. iOS中 读取相册,调用系统相机 技术分享

    技术内容:分别读取相册以及调取相机,将图片显示到imageView上 布局: 1.创建imageView 和 button 并为button一个关联pickerImage的事件 <div sty ...

  6. Android7.0调用系统相机拍照、读取系统相册照片+CropImageView剪裁照片

    Android手机拍照.剪裁,并非那么简单 简书地址:[我的简书–T9的第三个三角] 前言 项目中,基本都有用户自定义头像或自定义背景的功能,实现方法一般都是调用系统相机–拍照,或者系统相册–选择照片 ...

  7. Android 调用系统相机拍照保存以及调用系统相册的方法

    系统已经有的东西,如果我们没有新的需求的话,直接调用是最直接的.下面讲讲调用系统相机拍照并保存图片和如何调用系统相册的方法. 首先看看调用系统相机的核心方法: Intent camera = new ...

  8. 【踩坑速记】MIUI系统BUG,调用系统相机拍照可能会带给你的一系列坑,将拍照适配方案进行到底!

    一.写在前面 前几天也是分享了一些学习必备干货(还没关注的,赶紧入坑:传送门),也好久没有与大家探讨技术方案了,心里也是挺痒痒的,这不,一有点闲暇之时,就迫不及待把最近测出来的坑分享给大家. 提起An ...

  9. android调用系统相机并获取图片

    如果不是特别的要求,通过拍照的方式取得图片的话,我们一般调用系统的拍照来完成这项工作,而没必要再自己去实现一个拍照功能.调用系统相机很简单,只需要一个intent就可以跳转到相几界面,然后再通过onA ...

随机推荐

  1. HDU 4460 Friend Chains(map + spfa)

    Friend Chains Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total ...

  2. HDU1518:Square(DFS)

    Square Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submi ...

  3. HTTP的学习

    一个完整的HTTP请求: 1 简历TCP连接 2 web浏览器像web服务器发送请求命令 3 web浏览器发送请求头信息 4 web服务器应答 5 web服务器发送应答头信息 6 web服务器像浏览器 ...

  4. Effective java -- 4 泛型

    第二十三条:请不要在代码中使用原生态类型就是像Set这种待泛型的,就把泛型明确写出来. 第二十四条:消除非受检警告就是Set<String> sets = new HashSet();这种 ...

  5. VS2013编译FileZilla0.9.44

    2014年,FileZilla更新了一下,到了44版本了,貌似也是用VS2013的工程做的项目,所以下载了server的安装包,然后安装SourceCode即可(需要安装InterFace,是安装必选 ...

  6. ListView使用的时候遇到的一些问题

    昨天在做项目时,请求服务器的好友动态后,将好友动态和评论显示到界面上,用ListView显示,发现一进这个界面时,listView的适配器的getVIew()方法就会执行6次,后来发现原来是ListV ...

  7. 不停止MySQL服务增加从库的两种方式【转载】

    现在生产环境MySQL数据库是一主一从,由于业务量访问不断增大,故再增加一台从库.前提是不能影响线上业务使用,也就是说不能重启MySQL服务,为了避免出现其他情况,选择在网站访问量低峰期时间段操作. ...

  8. hibernate不能自动生成表的原因总结

    1. upate->create <property name="hbm2ddl.auto">create</property> 2. 2.Mappi ...

  9. 关于表单提交submit的兼容性问题。

    这里的form 表单 点击下载执行的函数名字是submit,这样不规范,submit是提交表单,函数名字不能取名叫submit,如果取名叫submit会在低版本的浏览器上无法识别,导致直接提交表单,无 ...

  10. gen_grant_sel.sql

    set echo off feedback off verify off pagesize 0 linesize 120 define v_grantee=&1 define v_grant_ ...