zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    (字符串)子串变位词
    反转链表 II
    翻转链表
    覆盖索引
    MySQL索引结构之Hash索引、full-text全文索引(面)
    MySQL索引结构之B+树索引(面)
    MYSQL 存储引擎(面)
    MySQL架构(面)
    如何在Linux Mint 20系统上安装Pip
    如何在CentOS 8系统服务器上安装Nginx
  • 原文地址:https://www.cnblogs.com/dinghing154/p/2619095.html
Copyright © 2011-2022 走看看