[IOS]——获取系统相册

   日期:2020-05-31     浏览:172    评论:0    
核心提示:效果图代码块#pragma mark - 实现picView的代理方法-(void)clickpicView:(UIButton *)btn{ //拿到获取相册的权限 if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]){ UIImagePickerController *pic = [[UIImagePickerC

效果图

代码块


#pragma mark - 实现picView的代理方法
-(void)clickpicView:(UIButton *)btn
{
    //拿到获取相册的权限
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]){
        UIImagePickerController *pic = [[UIImagePickerController alloc] init];
        pic.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
        pic.delegate = self;
        [self presentViewController:pic animated:YES completion:nil];
    }
}
//点击相片后会跑这个方法
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
     _sendphoto = YES;
    //拿到图片会就销毁之前的控制器
    [picker dismissViewControllerAnimated:YES completion:nil];
    //info中就是包含你在相册里面选择的图片
    UIImage *image = info[UIImagePickerControllerOriginalImage];
    //添加图片到view上
    UIImageView *imageV = [[UIImageView alloc] init];
    imageV.frame = CGRectMake(0, 0, 64, 64);
    imageV.backgroundColor = [UIColor blueColor];
    //把照片存起来
    _postImage = image;
    imageV.image = image;
    [_photoView addSubview:imageV];
    _imageV = imageV;
}
 
打赏
 本文转载自:网络 
所有权利归属于原作者,如文章来源标示错误或侵犯了您的权利请联系微信13520258486
更多>最近资讯中心
更多>最新资讯中心
0相关评论

推荐图文
推荐资讯中心
点击排行
最新信息
新手指南
采购商服务
供应商服务
交易安全
关注我们
手机网站:
新浪微博:
微信关注:

13520258486

周一至周五 9:00-18:00
(其他时间联系在线客服)

24小时在线客服