2012-03-06 110 views
3

我知道如何在ios4.2.1iPhone:如何从照片库或相机将像iPhone照片应用程序的“编辑”功能也有所

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

这个代码只是给我的形象,但我不能编辑它...

那么有没有什么不同的代码,这使得我能够编辑或裁剪我的图片像照片的应用程序

为更好地理解我上传followin屏幕截图。我从照片应用程序采取此屏幕截图。

enter image description here

在此先感谢。

+1

Edit是苹果在“照片”应用程序提供的功能。你必须自己编写代码 – Devang 2012-03-06 08:17:39

回答

1

我找到了一个链接,只要你想这是不一样的,但它可以帮助你

move and scale

0

正如Devang所建议的那样,我恐怕有这种方式可以从照片应用获取内置的编辑功能。

还有没有方式你可以访问私有API。 “照片”应用程序是苹果公司的应用程序,因此它具有的一些功能,公共API中的开发人员无法访问。

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

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

希望这可以帮助你。

+0

@Rohan:你有没有解决这个问题? – 2012-03-07 05:37:31

相关问题