设为首页 加入收藏

TOP

IOS 图片上传处理 图片压缩 图片处理(一)
2017-10-11 15:29:13 】 浏览:3697
Tags:IOS 图片 上传 处理 压缩

- (void)initActionSheet

{

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"我的相册",@"拍照", nil];

    actionSheet.tintColor = [UIColor whiteColor];

    

    [actionSheet showInView:self.scrollerViewUpload];

}

 

#pragma mark - UIActionSheetDelegate

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

    if (buttonIndex == 0)

    {

        UIImagePickerController *PickerController = [[UIImagePickerController alloc] init];

        PickerController.delegate = self;

        [self presentViewController:PickerController animated:YES completion:nil];

        

    }

    

    else if (buttonIndex == 1)

    {

        DNLog(@"拍照");

        

        

        UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;

        //判断是否有相机

        if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]){

            UIImagePickerController *picker = [[UIImagePickerController alloc] init];

            picker.delegate = self;

            //设置拍照后的图片可被编辑

            picker.allowsEditing = YES;

            //资源类型为照相机

            picker.sourceType = sourceType;

            [self presentViewController:picker animated:YES completion:nil];

            

        }else {

            [SVProgressHUD showWithStatus:@"没有照相功能" maskType:SVProgressHUDMaskTypeBlack];

            

            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

                [SVProgressHUD dismiss];

                

            });

            DNLog(@"没有照相功能");

            

        }

        

    }

    

}

 

 

#pragma mark - UIImagePickerControllerDelegate

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info

{

    UIImage *imageNew =info[UIImagePickerControllerOriginalImage];

    //设置image的尺寸

    CGSize imagesize = imageNew.size;

    imagesize.width = imageNew.size.width * 0.45;

    imagesize.height = imageNew.size.height *0.45;

    //对图片大小进行压缩--

    //&n

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇xib命名注意事项--防止被其他控制.. 下一篇一步步搭建react-native环境(苹果..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目