开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜