开发者

How do I Assign a Name to a Photo Saved in the Photo Library?

开发者 https://www.devze.com 2022-12-21 20:48 出处:网络
I am currently working on a project in which I have to save an image to the photo library and assign a name to each captured image.I know how to save the image, but how do you assign a name to the one

I am currently working on a project in which I have to save an image to the photo library and assign a name to each captured image. I know how to save the image, but how do you assign a name to the ones saved in the library?

My code:

-(void)imagePickerController:(UIImagePickerController *) picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{   
    [picker dismissModalViewControllerAnimated:YES];
    imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
     imgglobal =imageView.image;    


    //for saving image in photo library
    UIGraphicsBeginImageContext(self.imageView.bounds.size);


    [self.imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage =   UIGraphicsGetImageFromCurrentImageContext();
    UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
    UIGraphicsEndImageContext();
    UIImage *image1=imageView.image;
    [self imageSavedToPhotosAlbum:image1 didFinishSavingWithError:nil contextInfo:nil];          
} 

- (void)imageSavedToPhotosAlbum:(UIImage *)image  didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { 
        NSString *message;
        NSString *title;
        if (!error) {
            title = NSLocalizedString(@"SaveSuccessTitle", @"");
            message = NSLocalizedString(@"SaveSuccessMessage", @"");
        } else {
            title = NSLocalizedString(@"SaveFailedTitle", @"");
            message = [error description];
        }
        UIAlertView *alert = [[UIAler开发者_开发知识库tView alloc] initWithTitle:title
                                              message:message
                                              delegate:nil
                                              cancelButtonTitle:NSLocalizedString(@"OK", @"")
                                              otherButtonTitles:nil];
        [alert show];
        [alert release];
} 


The photos in the photo library does not contain any names. And you can't create a folder in the photo library either. If you really need a name to the photos, put it inside ~/Documents and implement your own chooser.

0

精彩评论

暂无评论...
验证码 换一张
取 消