您好,登录后才能下订单哦!
1 用途: 是系统提供的用来获取图片和视频的接口;
2获取图片途径:拍照,图库,相册获取
enum {
UIImagePickerControllerSourceTypePhotoLibrary ,
//来自图库
UIImagePickerControllerSourceTypeCamera ,
//来自相机
UIImagePickerControllerSourceTypeSavedPhotosAlbum
//来自相册
};
3 步骤:
初始化一个UIImagePickerController类
设置数据来源类型,—— 上面2
设置代理
如果需要对图片进行修改,allowsEditing = yes
4 具体代码实现
#pragma mark 选择图片
- (IBAction)selectImage:(UITapGestureRecognizer *)sender{
//图片选择控制器
UIImagePickerController *pickerController=[[UIImagePickerController alloc] init];
//选择你要使用的类型 图集,相册,相机 pickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
pickerController.delegate=self;
pickerController.allowsEditing=YES;
[self presentViewController:pickerController animated:YES completion:nil];
}
#pragma mark delegate
-(void)p_w_picpathPickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
//根据选择的图片 设置头像
_IconImage.p_w_picpath=info[@"UIImagePickerControllerOriginalImage"];
[picker dismissViewControllerAnimated:YES completion:^{
}];
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。