• iphone把图片保存到“照片”功能实现


    照片, 功能, 保存

    如何将指定的图片储存至系统的「照片」数据内,并检查储存动作是否成功

     程序提供加载预设的图片并提供一组UIButton按钮

     按下储存图片将检查此动作是否成功

    SavedToPhotoAlbumViewController.h

     1 #import <UIKit/UIKit.h>
     2 
     3 @interface SavedToPhotoAlbumViewController : UIViewController {
     4     IBOutlet UIImageView *myImageView;
     5 }
     6 
     7 @property (nonatomic,retain) UIImageView *myImageView;
     8 
     9 -(IBAction) SaveImageToPhotoAlbum:(id)sender;
    10 
    11 @end
    12 
    13 SavedToPhotoAlbumViewController.m
    14 
    15 
    16 @synthesize myImageView;
    17 
    18 -(IBAction) SaveImageToPhotoAlbum:(id)sender{
    19     UIImageWriteToSavedPhotosAlbum(myImageView.image, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:), nil);  
    20 }
    21 
    22 - (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
    23         NSString *message;
    24         NSString *title;
    25         if (!error) {
    26                 title = NSLocalizedString(@"储存成功", @"");
    27                 message = NSLocalizedString(@"您的图片已正确的储存至照片数据", @"");
    28         } else {
    29                 title = NSLocalizedString(@"储存失败", @"");
    30                 message = [error description];
    31         }
    32         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:titlemessage:message delegate:nil
    35         cancelButtonTitle:NSLocalizedString(@"", @"") otherButtonTitles:nil];
    37         [alert show];
    38         [alert release];
    39 }
  • 相关阅读:
    Git----远程仓库01
    Git--时光穿梭机之删除文件06
    Git----时光穿梭机之撤销修改05
    Git----时光穿梭机之管理修改04
    Git----时光穿梭机之工作区和暂存区03
    Git---时光穿梭机之版本回退02
    Git----时光穿梭机01
    Git---创建版本库
    python自动化之鼠标移动
    python自动化之excel
  • 原文地址:https://www.cnblogs.com/dinghing154/p/2619095.html
Copyright © 2020-2023  润新知