OGeek|极客世界-中国程序员成长平台

标题: ios - 图像的裁剪选项 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 09:07
标题: ios - 图像的裁剪选项

我想从相册中选择图片并用相机拍摄。它的代码运行良好,但我只需要选择部分图像意味着裁剪图像集我的 imageView。

-(IBAction)chooseAlbumid)sender
{
    imagePicker=[[UIImagePickerController alloc]init];
    imagePicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.delegate=self;
    [self presentViewController:imagePicker animated:YES completion:nil];
}

-(IBAction)takePictureid)sender
{
    imagePicker=[[UIImagePickerController alloc]init];
    imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera;
    imagePicker.delegate = self;

    [self presentViewController:imagePicker animated:YES completion:nil];
}

-(void)imagePickerControllerUIImagePickerController*)picker didFinishPickingMediaWithInfoNSDictionary*)info
{
     profileImageView.image=[info objectForKey:UIImagePickerControllerOriginalImage];

    [self dismissViewControllerAnimated:YES completion:nil];
}



Best Answer-推荐答案


开启编辑模式

imagePicker.allowsEditing = YES;

然后在您的委托(delegate)方法中使用 UIImagePickerControllerEditedImage

-(void)imagePickerControllerUIImagePickerController*)picker didFinishPickingMediaWithInfoNSDictionary*)info {
    profileImageView.image=[info objectForKey:UIImagePickerControllerEditedImage];
    [self dismissViewControllerAnimated:YES completion:nil];
}

关于ios - 图像的裁剪选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32835289/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4