Image editing on iphone
In my app i need to select a image from photos library and then user should be able to crop or scale the the image. Can an开发者_开发问答y one please help me?
UIImagePickerController should do the trick.
UIImagePickerController *picker = [UIImagePickerController new];
picker.delegate = self;
picker.allowsEditing = YES;
[yourViewController presentModalViewController:picker];
Then we need to implement the delegate method:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
}
You can use a UIImagePickerController
to let the user select an image from the photos library.
@denizen
The
[yourViewController presentModalViewController:picker];
needs an animated:BOOL.
Like: [yourViewController presentModalViewController:picker animated:YES];
You can also have a look at SSPhotoCropperViewController. It’s a custom view controller that provides a simple, configurable and easy-to-use UI for cropping and scaling photos in iPhone & iPod Touch apps.
For picking photos from the Photo Library, UIImagePickerController does well. However you cannot use it for the photos you get from another sources, say Flickr, FB etc.
Here is the tutorial and the source code on GitHub for SSPhotoCropperViewController.
精彩评论