iPhone上的图像编辑

问题描述:

在我的应用程序中,我需要从照片库中选择图像,然后用户应该能够裁剪或缩放图像。谁能帮帮我吗?iPhone上的图像编辑

UIImagePickerController应该做的伎俩。

UIImagePickerController *picker = [UIImagePickerController new]; 
picker.delegate = self; 
picker.allowsEditing = YES; 
[yourViewController presentModalViewController:picker]; 

然后,我们需要实现的委托方法:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; 
} 
+0

使用UIImagePickerController我们可以编辑图像吗? – PgmFreek 2010-11-08 04:34:32

+0

通过设置picker.allowsEditing,控制器会自动让用户裁剪并缩放,然后再返回给您。 – denizen 2010-11-08 04:37:22

+0

如何在选择器模式视图中将“选择”按钮名称更改为“完成”? – PgmFreek 2010-11-08 06:22:14

可以使用UIImagePickerController让用户选择从照片库中的图像。

+0

我知道。但我如何编辑图像? – PgmFreek 2010-11-08 04:33:39

@denizen [yourViewController presentModalViewController:picker];需要动画:BOOL。

像:[yourViewController presentModalViewController:picker animated:YES];

你也可以看看SSPhotoCropperViewController。这是一个自定义视图控制器,提供了一个简单,可配置和易于使用的用户界面,用于在iPhone & iPod Touch应用中裁剪和缩放照片。

对于从照片库中选取照片,UIImagePickerController表现不错。但是,您不能将其用于从其他来源获得的照片,例如Flickr,FB等。

以下是SSPhotoCropperViewController的tutorialsource code on GitHub