我想从相册中选择图片并用相机拍摄。它的代码运行良好,但我只需要选择部分图像意味着裁剪图像集我的 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-推荐答案 strong>
开启编辑模式
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/
|