• 相册操作


    /*

    #pragma mark -点击图片显示大图-
    -(void)addEnvironment:(int) index
    {
        WZPreviewPictureViewController * pp = [[WZPreviewPictureViewController alloc] init];
        pp.urlString = [((NSString *)[self.datalist objectAtIndex:index]) changeBigImage];
        self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
        [self presentViewController:pp animated:YES completion:nil];
        [pp release];
    }



    // 将图片转换为JPG格式的二进制数据上传
    - (void)shangchuantupian
    {
        NSData *data = UIImageJPEGRepresentation(self.productPic.image, 1); //将图片转换为JPG格式的二进制数据上传
        [_requestCommon setData:data withFileName:@"coupon.jpg" andContentType:@"image/jpeg" forKey:@"imgpath"];
    }
    - (void)actionSheet
    {
        
    #warning 系统版本高于 8.0 调用此方法
        UIAlertController *pictureSelectAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

        UIAlertAction *takePhoto = [UIAlertAction actionWithTitle:JZLTakePhoto style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // 照相
            
            [self JZLTakePhotos];
        }];
        UIAlertAction *selectPhoto = [UIAlertAction actionWithTitle:JZLSelectPhoto style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // 从相册选择
            
            [self JZLSelectPhotos];
        }];
        UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];

        [pictureSelectAlert addAction:takePhoto];
        [pictureSelectAlert addAction:selectPhoto];
        [pictureSelectAlert addAction:cancel];

        [self presentViewController:pictureSelectAlert animated:YES completion:nil];
    }
    // 照相
    - (void)JZLTakePhotos
    {
        UIImagePickerController *_ipcCamera = [[UIImagePickerController alloc] init];
        _ipcCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
        _ipcCamera.delegate = self;
        _ipcCamera.allowsEditing = YES;
        [self presentViewController:_ipcCamera animated:YES completion:nil];
        [_ipcCamera release];
    }
    // 从相册选择
    - (void)JZLSelectPhotos
    {
        UIImagePickerController *_ipcPhoto = [[UIImagePickerController alloc] init];
        _ipcPhoto.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        _ipcPhoto.delegate = self;
        _ipcPhoto.allowsEditing = YES;
        [self presentViewController:_ipcPhoto animated:YES completion:nil];
        [_ipcPhoto release];
    }
    #pragma mark ----UIImagePickerControllerDelegate methods
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        NSLog(@"%@", info);
        
        UIImage *img = nil;
        if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { // 相机获得
            
            //如果是 来自照相机的image,那么先保存UIImagePickerControllerEditedImage
            UIImage *OriginalImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
            UIImageWriteToSavedPhotosAlbum(OriginalImage, self, nil, nil);
            
            // 获得编辑过的图片
            img = [info objectForKey:@"UIImagePickerControllerEditedImage"];
            
        } else if (picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) { // 相册获得
            
            img = [info objectForKey:@"UIImagePickerControllerEditedImage"];
        }
        
        UIImage *pressedImg = nil;
        // 压缩
        if (img.size.width >300 || img.size.height > 300) {
            
            float scale = 300.0 / img.size.width;
            CGSize size = CGSizeMake(img.size.width * scale, img.size.height * scale);
            
            pressedImg = [self imageWithImageSample:img scaleToSize:size];
        } else {
            
            pressedImg = img;
        }
        
        [picker dismissViewControllerAnimated:YES completion:^{
            
            [self.productPic setImage:pressedImg];
        }];
    }
    // 照片压缩
    - (UIImage *)imageWithImageSample:(UIImage *)image scaleToSize:(CGSize)size
    {
        UIGraphicsBeginImageContext(size);
        
        [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
        
        UIImage *pressedIMG = UIGraphicsGetImageFromCurrentImageContext();
        
        UIGraphicsEndImageContext();
        
        return pressedIMG;
    }

    */

  • 相关阅读:
    结对编程作业
    软工网络15个人阅读作业2——提问题
    软件工程 网络15个人阅读作业1
    java课程设计---彩票销售管理系统
    201521123122 《java程序设计》第十四周学习总结
    201521123122 《java程序设计》第十三周学习总结
    201521123122 《java程序设计》第十二周学习总结
    个人作业5
    软工网络15个人作业4——alpha阶段个人总结
    软工个人随笔3 罗骏 201521123121
  • 原文地址:https://www.cnblogs.com/jzlblog/p/4333303.html
Copyright © 2020-2023  润新知