iPhone:如何使用 "edit"功能从照片库或相机中获取图像,如 iPhone 照片应用程序

标签 iphone objective-c ios5 photo-gallery

我知道如何在 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];
}
}

这段代码只是给我图像,但我无法编辑它...

那么有没有什么不同的代码可以让我像照片应用一样编辑或裁剪我的图像

为了更好地理解,我上传了以下屏幕截图。我从照片应用程序中截取了这个屏幕截图。

enter image description here

提前致谢。

最佳答案

我找到了一个与你想要的不一样的链接,但它可能对你有帮助

move and scale

关于iPhone:如何使用 "edit"功能从照片库或相机中获取图像,如 iPhone 照片应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9579548/

相关文章:

ios - 缩放 GMSMapView 以适应 GMSMarker 标记?

ios - iPad 显示阵列中的图像

iphone - 在 iPhone 上打开热点会导致我的应用程序屏幕向下移动

iphone - 呈现模态视图有时会隐藏导航栏

iphone开发: controlling UITableViewCell

objective-c - NSUserDefaults 由于内存崩溃而被删除?

javascript - 在 iPhone 浏览器上下载 VCF 文件

java - 有没有什么方法可以找到我的 wifi 网络中最近接入点的 IP 地址?

ios - UIActivityIndi​​catorView 在出现在 transitionWithView 中后没有动画

pdf - UIWebView内容高度在scrollview.contentsize中不正确