iPhone 上的图像编辑

发布于 2024-10-01 02:07:46 字数 53 浏览 6 评论 0 原文

在我的应用程序中,我需要从照片库中选择图像,然后用户应该能够裁剪或缩放图像。有人可以帮我吗?

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 any one please help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一绘本一梦想 2024-10-08 02:07:46

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];
}

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];
}
放飞的风筝 2024-10-08 02:07:46

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

You can use a UIImagePickerController to let the user select an image from the photos library.

意中人 2024-10-08 02:07:46

@denizen

[yourViewController PresentModalViewController:picker]; 需要一个动画:BOOL。

像:[yourViewController PresentModalViewController:pickeranimated:YES];

@denizen
The
[yourViewController presentModalViewController:picker]; needs an animated:BOOL.

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

流年已逝 2024-10-08 02:07:46

您还可以查看 SSPhotoCropperViewController。它是一个自定义视图控制器,提供简单、可配置且易于使用的 UI,用于在 iPhone 和 iPad 上裁剪和缩放照片。 iPod Touch 应用程序。

对于从照片库中挑选照片,UIImagePickerController 做得很好。但是,您不能将其用于从其他来源(例如 Flickr、FB 等)获取的照片。

这是 教程GitHub 上的源代码

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文