照片Controller弹出及选择

Posted on 2016-07-06 17:32  柠檬片  阅读(101)  评论(0)    收藏  举报
 1 //选择照片
 2 - (IBAction)chosePic:(id)sender {
 3     
 4     //系统相册控制器
 5     UIImagePickerController *pickVC = [[UIImagePickerController alloc] init];
 6     
 7     //设置照片的来源
 8     pickVC.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
 9     
10     //设置代理
11     pickVC.delegate = self;
12     //modal出系统相册控制器
13     [self presentViewController:pickVC animated:YES completion:nil];
14     
15 }
弹出系统相册控制器
 1 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
 2 {
 3     //获取当前选中的图片.通过UIImagePickerControllerOriginalImage就能获取.
 4     UIImage *image = info[UIImagePickerControllerOriginalImage];
 5     
 6     HandleImageView *handView = [[HandleImageView alloc] init];
 7     handView.frame = self.drawView.bounds;
 8     handView.image = image;
 9     handView.delegate = self;
10 
11     
12     NSLog(@"%@", handView.backgroundColor);
13     [self.drawView addSubview:handView];
14     
15     //    self.drawView.image = image;
16     //让系统相册控制器消失
17     [self dismissViewControllerAnimated:YES completion:nil];
18     
19 }
实现代理方法