我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

[IOS]Photo应用

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

操作步骤:

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

2.修改ViewController

ViewController.h:

创新互联建站专注骨干网络服务器租用10余年,服务更有保障!服务器租用,资阳主机托管 成都服务器租用,成都服务器托管,骨干网络带宽,享受低延迟,高速访问。灵活、实现低成本的共享或公网数据中心高速带宽的专属高性能服务器。

#import  @interface DXWViewController : UIViewController @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应用

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


分享标题:[IOS]Photo应用
分享网址:http://shouzuofang.com/article/jiiohi.html

其他资讯