IOS获取图片音频方法----UIImagePickerController
1 用途: 是系统提供的用来获取图片和视频的接口;
镇江网站建设公司创新互联,镇江网站设计制作,有大型网站制作公司丰富经验。已为镇江上千多家提供企业网站建设服务。企业网站搭建\成都外贸网站建设要多少钱,请找那个售后服务好的镇江做网站的公司定做!
2获取图片途径:拍照,图库,相册获取
enum {
UIImagePickerControllerSourceTypePhotoLibrary ,
//来自图库
UIImagePickerControllerSourceTypeCamera ,
//来自相机
UIImagePickerControllerSourceTypeSavedPhotosAlbum
//来自相册
};
3 步骤:
初始化一个UIImagePickerController类
设置数据来源类型,—— 上面2
设置代理
如果需要对图片进行修改,allowsEditing = yes
4 具体代码实现
#pragma mark选择图片
- (IBAction)selectImage:(UITapGestureRecognizer *)sender{
//图片选择控制器
UIImagePickerController *pickerController=[[UIImagePickerControlleralloc]init];
//选择你要使用的类型图集,相册,相机 pickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
pickerController.delegate=self;
pickerController.allowsEditing=YES;
[selfpresentViewController:pickerControlleranimated:YEScompletion:nil];
}
#pragma mark delegate
-(void)p_w_picpathPickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary
//根据选择的图片设置头像
_IconImage.p_w_picpath=info[@"UIImagePickerControllerOriginalImage"];
[pickerdismissViewControllerAnimated:YEScompletion:^{
}];
}
当前文章:IOS获取图片音频方法----UIImagePickerController
本文来源:http://azwzsj.com/article/gidhsg.html