简体   繁体   English

iPhone:如何通过iPhone照片应用程序等“编辑”功能从照片库或相机中获取图像

[英]iPhone:How to fetch image from photo library or camera with “edit” funcitionality like iPhone photo app

I know how to fetch image from photo library or camera in ios4.2.1 我知道如何从ios4.2.1中的照片库或相机中获取图像

but in ios 5 there is new feature in photo app like if user wants to edit image or crop image then he is able to do such kind of things. 但是在ios 5中,照片应用程序中有新功能,例如,如果用户想要编辑图像或裁剪图像,那么他就可以做这样的事情。

The same functionality I want to implement in my app when I grab image from camera or photo library. 当我从相机或照片库中抓取图像时,我希望在我的应用中实现相同的功能。

the code by which I fetched image in ios 4.2.1 works also in ios 5 but by this code I am not able to edit or crop my image. 我在ios 4.2.1中获取图像的代码也适用于ios 5,但是通过这段代码,我无法编辑或裁剪图像。

My code is as follows: 我的代码如下:

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

This code simply give me the image but I am not able to edit it... 这段代码只是给我图像,但我无法编辑它...

then is there any different code which make me able to edit or crop my image like photo app 然后是否有任何不同的代码,使我能够编辑或裁剪我的图像,如照片应用程序

for better understanding I upload followin screen shot. 为了更好地理解我上传跟随屏幕截图。 I take this screen shot from photo app. 我从照片应用程序拍摄这个屏幕截图。

在此输入图像描述

thanks in advance. 提前致谢。

I found one link which is not same as you want but it might help you 我找到了一个与你想要的不一样的链接,但它可能对你有帮助

move and scale 移动和扩展

As Devang has suggested, I am afraid that there is NO way you can get the inbuilt Edit from the Photos app. 正如Devang建议的那样,我担心没有办法从Photos应用程序中获取内置的Edit。

There is no way you can get access to Private API . 没有办法,你可以访问私有API。 "Photos" app is the Apple's application and hence it has some features which are not accessible by the developers in Public API . “Photos”应用程序是Apple的应用程序,因此它具有一些开发人员无法访问的功能

Now the point is that you can only create and instance of photo library or camera and grab an image from there. 现在重点是你只能创建照片库或照相机的实例,并从那里抓取图像。 But there is no way you can access the "Edit" function of the Photos application. 但是你无法访问Photos应用程序的“Edit”功能。

If at all you require to do it, then you need to find a way to code all the functionalities by yourself. 如果您需要这样做,那么您需要找到一种方法来自己编写所有功能。

Hope this helps you. 希望这对你有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM