IOS 七牛上传多张图片

// 调用图片选择器

- (void)callImagePicker{  

    [self.viewendEditing:YES];

    UIActionSheet *sheet = [[UIActionSheetalloc]initWithTitle:@"选择图片来源"delegate:selfcancelButtonTitle:@"取消"destructiveButtonTitle:nilotherButtonTitles:@"拍照",@"从手机相册选择",nil];

    [sheet showInView:self.view];

}



#pragma mark - actionSheet的协议方法 -----继续上传图片

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

    UIImagePickerController *ipVC = [[UIImagePickerControlleralloc]init];

    ipVC.delegate =self;

    ipVC.modalTransitionStyle =UIModalTransitionStyleCoverVertical;

    

    if (buttonIndex ==0) {

        

        BOOL isCamera = [UIImagePickerControllerisCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear];

        if (isCamera) {

            ipVC.sourceType =UIImagePickerControllerSourceTypeCamera;

            [selfpresentViewController:ipVCanimated:YEScompletion:nil];

        }

    }elseif(buttonIndex==1){

        

        //        ipVC.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

        QBImagePickerController *imagePickerController = [[QBImagePickerControlleralloc]init];

        imagePickerController.delegate =self;

        imagePickerController.allowsMultipleSelection =YES;

        imagePickerController.minimumNumberOfSelection =1;

        imagePickerController.maximumNumberOfSelection =9;

        imagePickerController.hidesBottomBarWhenPushed=YES;

        UINavigationController *navigationController = [[UINavigationControlleralloc]initWithRootViewController:imagePickerController];

        [selfpresentViewController:navigationControlleranimated:YEScompletion:NULL];

        

    }else{

        

        

    }

    

    

}


- (void)dismissImagePickerController

{

    if (self.presentedViewController) {

        [selfdismissViewControllerAnimated:YEScompletion:NULL];

    } else {

        [self.navigationControllerpopToViewController:selfanimated:YES];

    }

}



#pragma mark - QBImagePickerControllerDelegate


- (void)imagePickerController:(QBImagePickerController *)imagePickerController didSelectAsset:(ALAsset *)asset

{

    NSLog(@"*** imagePickerController:didSelectAsset:");

    NSLog(@"%@", asset);

    

    [selfdismissImagePickerController];

}


- (void)imagePickerController:(QBImagePickerController *)imagePickerController didSelectAssets:(NSArray *)assetss

{

    NSLog(@"assetss:%@",assetss);

    

    NSMutableArray *imagesArr = [[NSMutableArrayalloc]init];

    UIImage *originImage ;

    for (int i=0; i<assetss.count; i++) {

        originImage = [UIImageimageWithCGImage:[[assetssobjectAtIndex:i]aspectRatioThumbnail]];

        [imagesArr addObject:originImage];

    }

    

    //

    [UploadImageTooluploadImages:imagesArrprogress:^(CGFloat progress) {

        

        NSLog(@"qin niu --%f",progress);

        

    } success:^(NSArray *urlArr) {

        

        NSLog(@"qin niu --%@",urlArr);

        

        for (int i=0; i<urlArr.count; i++) {

            if (imageData.count<10) {

                [imageDatainsertObject:urlArr[i]atIndex:imageData.count-1];

            }

        }

        

        if (imageData.count==0) {

            _collectionView.height =120;

        }elseif (imageData.count<=3) {

            _collectionView.height =120;

        }elseif (imageData.count>3&&imageData.count<=6){

            _collectionView.height =240;

        }elseif (imageData.count>6&&imageData.count<=10){

            _collectionView.height =350;

        }

        

        thirdView.height =_collectionView.bottom;

        fistView.top =thirdView.bottom+10;

        fourView.top =fistView.bottom+10;

        commitBtn.top =fourView.bottom+50;

        _scrollView.contentSize =CGSizeMake(0,commitBtn.bottom+20);

        [_collectionViewreloadData];

        

    } failure:^{

        

        NSLog(@" --->> error:   ");

        

    }];

    

    

    [selfdismissImagePickerController];

}



#pragma mark - UIImagePickerController 代理方法

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

    //对获取的图片进行一些处理

    UIImage *image = [infoobjectForKey:@"UIImagePickerControllerOriginalImage"];

    //

    [UploadImageTooluploadImages:@[image]progress:^(CGFloat progress) {

        

        NSLog(@"qin niu --%f",progress);

        

    } success:^(NSArray *urlArr) {

        

        NSLog(@"qin niu --%@",urlArr);

        

        if (imageData.count<10) {

            [imageDatainsertObject:urlArr[0]atIndex:imageData.count-1];

        }

        

        if (imageData.count==0) {

            _collectionView.height =120;

        }elseif (imageData.count<=3) {

            _collectionView.height =120;

        }elseif (imageData.count>3&&imageData.count<=6){

            _collectionView.height =240;

        }elseif (imageData.count>6&&imageData.count<=10){

            _collectionView.height =350;

        }

        

        thirdView.height =_collectionView.bottom;

        fistView.top =thirdView.bottom+10;

        fourView.top =fistView.bottom+10;

        commitBtn.top =fourView.bottom+50;

        _scrollView.contentSize =CGSizeMake(0,commitBtn.bottom+20);

        [_collectionViewreloadData];

        

    } failure:^{

        

        NSLog(@" --->> error:   ");

        

    }];

    

    [picker dismissViewControllerAnimated:YEScompletion:nil];

    

}

- (void)imagePickerControllerDidCancel:(QBImagePickerController *)imagePickerController

{

    NSLog(@"*** imagePickerControllerDidCancel:");

    [selfdismissImagePickerController];

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值