2012-12-11 88 views
0

嗨对不起,但我正在学习。我的Fgallery在我的应用程序中工作,但现在我想将一个栏按钮连接到一个操作以将图像保存到手机中。我需要一些代码给我当前图像(在大图像视图中),我希望有人能帮助我解决这个问题。这是我有:Fgallery将图像保存到iPhone

- (void)handleEditCaptionButtonTouch:(id)sender { 
// here we could implement some code to change the caption for a stored image 
[networkGallery saveImageAtIndex:[networkGallery currentIndex]]; 

}

在这里,我有一个形象的硬编码,但我需要当前图像:

- (void)saveImageAtIndex:(NSUInteger)index 
{ 

UIImage *image = [UIImage imageNamed:@"background.png"]; 
if(image != nil){ 
    UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 
} 
return; 

} 


//saveImage method 
-(void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{ 
[BT_debugger showIt:self:[NSString stringWithFormat:@"finished saving image: %@", @""]]; 
NSString *message; 
NSString *title; 
if (!error) { 
    title = NSLocalizedString(@"SaveSuccessTitle", @""); 
    message = NSLocalizedString(@"SaveSuccessMessage", @""); 
} else { 
    title = NSLocalizedString(@"SaveFailedTitle", @""); 
    message = [error description]; 
} 
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title 
               message:message 
               delegate:nil 
             cancelButtonTitle:NSLocalizedString(@"ButtonOK", @"") 
             otherButtonTitles:nil]; 
[alert show]; 
[alert release]; 
} 

任何帮助将是非常赞赏。

在此先感谢 DK

回答

0

如果其他人正在寻找一个答案。在这里它是:[的NSString stringWithFormat:@“%I

FGalleryPhoto *photo = [_photoLoaders objectForKey:[NSString stringWithFormat:@"%i", index]]; 
UIImage *saveImage = [photo fullsize]; 
0
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
img.image = [info valueForKey:@"UIImagePickerControllerOriginalImage"]; 

[self dismissModalViewControllerAnimated:YES]; 
} 
+0

嗨感谢您的回应并试图提供帮助。 saveImageAtIndex中应该怎么做才能将当前图像保存到手机中? UIImage * image = [UIImage imageNamed:@“background.png”];应该改成像tis这样的东西:UIImage * image = the_current_image;但当然the_current_image应该是别的东西,我不知道它应该是什么。希望你能帮助我,并提前致谢 – Danny

+0

更新了答案。 – Sam

+0

谢谢萨姆。我希望我会这么简单。但它不知道CurrentImage,这就是我需要找到的:什么是(代码)当前图像.....真的很感谢这个山姆!为您的信息:与硬编码图像的代码完美的作品 – Danny

0

在上面的代码中,在stringWithFormat方法,用_currentIndex

FGalleryPhoto *相片= [_photoLoaders objectForKey取代指数 “,_currentIndex]]; UIImage * saveImage = [photo fullsize];