Fgallery将图像保存到iPhone

时间:2012-12-11 00:13:04

标签: iphone ios image

你好抱歉我是个菜鸟但是我正在学习。我的Fgallery在我的应用程序中工作但现在我想将一个条形按钮连接到动作以将图像保存到手机中。我需要一些代码来给我当前的图像(在大图像视图中)我希望有人可以帮我解决这个问题。这就是我所拥有的:

- (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

3 个答案:

答案 0 :(得分:0)

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
 img.image = [info valueForKey:@"UIImagePickerControllerOriginalImage"];

 [self dismissModalViewControllerAnimated:YES];
}

答案 1 :(得分:0)

如果其他人正在寻找答案。这是:

FGalleryPhoto *photo = [_photoLoaders objectForKey:[NSString stringWithFormat:@"%i", index]];
UIImage *saveImage = [photo fullsize];

答案 2 :(得分:0)

在上面的代码中,在 stringWithFormat 方法中,将 index 替换为 _currentIndex

FGalleryPhoto * photo = [_photoLoaders objectForKey:[NSString stringWithFormat:@“%i”,_ currentIndex]]; UIImage * saveImage = [photo fullsize];