[IOS]Photo应用

发布时间:2020-07-12 03:40:25 作者:蓬莱仙羽
来源:网络 阅读:316

IOS应用开发,如何加载图片库中的Image到view中?下面我们来学习一下吧!

操作步骤:

1.创建一个SingleView的项目,然后启动模拟器,点击模拟器上的浏览器,然后将本地的图片拖放上去,然后点击图片长按,点击saveImage到图片库。

2.修改ViewController

ViewController.h:

#import <UIKit/UIKit.h> @interface DXWViewController : UIViewController<UIImagePickerControllerDelegate,UINavigationControllerDelegate> @property (retain, nonatomic) IBOutlet UIImageView *imageView; @property (retain, nonatomic) IBOutlet UIButton *Button; @property(retain,nonatomic) UIImage *image; - (IBAction)click:(id)sender; @end

ViewController.m:

#import "DXWViewController.h"  @interface DXWViewController ()  @end  @implementation DXWViewController  - (void)viewDidLoad {     [super viewDidLoad]; 	 }  -(void)viewWillAppear:(BOOL)animated {     self.imageView.image = self.image; } //加载成功 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {     self.Image = [info objectForKey:UIImagePickerControllerEditedImage];     [picker dismissViewControllerAnimated:YES completion:nil]; } //取消 -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {     [picker dismissViewControllerAnimated:YES completion:nil]; }  - (void)dealloc {     [_imageView release];     [_image release];     [_Button release];     [super dealloc]; } //打开图库获取图片 - (IBAction)click:(id)sender {     if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {         UIImagePickerController *picker = [[UIImagePickerController alloc] init];         picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;         picker.delegate = self;         picker.allowsEditing = YES;         [self presentViewController:picker animated:YES completion:nil];     } } @end


运行结果:

[IOS]Photo应用[IOS]Photo应用[IOS]Photo应用[IOS]Photo应用

demo文件:http://download.csdn.net/detail/s10141303/6037575

推荐阅读:
  1. 如何安装和配置Maxscale?
  2. 查询域账户密码的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

pho

上一篇:plsql连接Oracle11g 64位数据库导出dmp文件一闪而过

下一篇:php文件上传大小的限制

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》