![](/img/trans.png)
[英]How to Fetch image from Photo Library or Camera with Edit functionality like iPhone
[英]iPhone:How to fetch image from photo library or camera with “edit” funcitionality like iPhone photo app
我知道如何從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];
}
}
這段代碼只是給我圖像,但我無法編輯它...
然后是否有任何不同的代碼,使我能夠編輯或裁剪我的圖像,如照片應用程序
為了更好地理解我上傳跟隨屏幕截圖。 我從照片應用程序拍攝這個屏幕截圖。
提前致謝。
我找到了一個與你想要的不一樣的鏈接,但它可能對你有幫助
正如Devang建議的那樣,我擔心沒有辦法從Photos應用程序中獲取內置的Edit。
有沒有辦法,你可以訪問私有API。 “Photos”應用程序是Apple的應用程序,因此它具有一些開發人員無法訪問的功能 。
現在重點是你只能創建照片庫或照相機的實例,並從那里抓取圖像。 但是你無法訪問Photos應用程序的“Edit”功能。
如果您需要這樣做,那么您需要找到一種方法來自己編寫所有功能。
希望這對你有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.