创新互联建站专注骨干网络服务器租用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
#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