UIImageView -- 选择图片

2018-07-20    来源:open-open

容器云强势上线!快速搭建集群,上万Linux镜像随意使用
- (void)viewDidLoad
{
    [super viewDidLoad];
     
     
    _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
    [self.view addSubview:_imageView];
    _imageView.backgroundColor = [UIColor redColor];
    //
     
    _imageView.userInteractionEnabled = YES;
     
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(choosePictrue)];
    //tap.numberOfTapsRequired  = 2;
    [_imageView addGestureRecognizer:tap];
    [tap release];
    [_imageView release];
         
}
 
- (void)choosePictrue{
    UIImagePickerController *picc = [[UIImagePickerController alloc] init];
    picc.delegate = self;
    picc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentViewController:picc animated:YES completion:nil];
    [picc release];
}
 
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    _imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [picker dismissViewControllerAnimated:YES completion:nil];
     
}
 
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
 
    [picker dismissViewControllerAnimated:YES completion:nil];
}
@end

标签: idc

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。

上一篇:jquery 改变textarea高度

下一篇:sqlite操作Js类