2012-03-06 113 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

相關問題