Reputation: 377
I want to choose picture from album and taking by Camera. It code work well but I need to select only part of image means cropping of image set my imageView.
-(IBAction)chooseAlbum:(id)sender
{
imagePicker=[[UIImagePickerController alloc]init];
imagePicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate=self;
[self presentViewController:imagePicker animated:YES completion:nil];
}
-(IBAction)takePicture:(id)sender
{
imagePicker=[[UIImagePickerController alloc]init];
imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
profileImageView.image=[info objectForKey:UIImagePickerControllerOriginalImage];
[self dismissViewControllerAnimated:YES completion:nil];
}
Upvotes: 2
Views: 105
Reputation: 331
you have to just add property imagePicker.
imagePicker.allowsEditing = YES;
Upvotes: 1
Reputation: 217
However you can also use the following third party library if you want more control and pleasant effect/animation.
https://github.com/myang-git/iOS-Image-Crop-View
Upvotes: 0
Reputation: 40018
Turn on the editing mode
imagePicker.allowsEditing = YES;
Then in your delegate method use UIImagePickerControllerEditedImage
key
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info {
profileImageView.image=[info objectForKey:UIImagePickerControllerEditedImage];
[self dismissViewControllerAnimated:YES completion:nil];
}
Upvotes: 2