【问题标题】:iPhone:How to fetch image from photo library or camera with "edit" funcitionality like iPhone photo appiPhone:如何使用 iPhone 照片应用程序等“编辑”功能从照片库或相机中获取图像
【发布时间】:2012-03-06 07:28:13
【问题描述】:

我知道如何在 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 objective-c ios5 photo-gallery


【解决方案1】:

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

move and scale

【讨论】:

    【解决方案2】:

    正如 Devang 所建议的那样,恐怕没有NO可以从照片应用程序中获取内置编辑功能。

    没有您可以访问 Private API。 “照片”应用程序是 Apple 的应用程序,因此它具有开发人员在公共 API 中无法访问的一些功能

    现在的重点是,您只能创建照片库或相机的实例并从那里抓取图像。但是您无法访问照片应用程序的“编辑”功能。

    如果您确实需要这样做,那么您需要找到一种方法来自己编写所有功能。

    希望对你有所帮助。

    【讨论】:

    • @Rohan:你有什么解决办法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多