我知道如何在 ios4.2.1 中从照片库或相机中获取图像
但在 iOS 5 中,照片应用程序中有一个新功能,比如如果用户想要编辑图像或裁剪图像,那么他就可以执行此类操作。
当我从相机或照片库抓取图像时,我想在我的应用中实现相同的功能。
我在 ios 4.2.1 中获取图像的代码也适用于 ios 5,但通过这段代码我无法编辑或裁剪我的图像。
我的代码如下:
- (IBAction)btnCapturePressed:(id)sender {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
ipc=[[UIImagePickerController alloc] init ];
ipc.delegate=self;
ipc.sourceType=UIImagePickerControllerSourceTypeCamera;
//btnUserImage.tag=-2;
[self presentModalViewController:ipc animated:YES];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Nemo Rating" message:@"Camera capture is not supported in this device" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
-(void) imagePickerController:(UIImagePickerController *) picker didFinishPickingMediaWithInfo :(NSDictionary *)info
{
UIImage *imageToScale=[info objectForKey:UIImagePickerControllerOriginalImage];
// imageToScale=[imageToScale imageByScalingAndCroppingForSize:CGSizeMake(20,10)];
imageToScale=[imageToScale scaleToSize:CGSizeMake(95, 86)];
[btnUserImage setImage:imageToScale forState:UIControlStateNormal];
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if(version >= 5.0)
{
[[picker presentingViewController] dismissModalViewControllerAnimated:YES];
[picker release];
}
else
{
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
//[picker popViewControllerAnimated:YES];
[picker release];
}
}
这段代码只是给我图像,但我无法编辑它...
那么有没有什么不同的代码可以让我像照片应用一样编辑或裁剪我的图像
为了更好地理解,我上传了以下屏幕截图。我从照片应用程序中截取了这个屏幕截图。
提前致谢。
最佳答案
我找到了一个与你想要的不一样的链接,但它可能对你有帮助
关于iPhone:如何使用 "edit"功能从照片库或相机中获取图像,如 iPhone 照片应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9579548/