码迷,mamicode.com
首页 > 其他好文 > 详细

对图库的操作

时间:2016-03-08 13:18:47      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

选择相册: UIImagePickerControllerSourceTypesourceType=UIImagePickerControllerSourceTypeCamera;  
   if (![UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {  
       sourceType=UIImagePickerControllerSourceTypePhotoLibrary;  
   }  
   UIImagePickerController * picker = [[UIImagePickerControlleralloc]init];  
   picker.delegate = self;  
   picker.allowsEditing=YES;  
   picker.sourceType=sourceType;  
   [self presentModalViewController:picker animated:YES];  
选择完毕:  -(void)imagePickerController:(UIImagePickerController*)pickerdidFinishPickingMediaWithInfo:(NSDictionary *)info  
{  
   [picker dismissModalViewControllerAnimated:YES];  
   UIImage * image=[info objectForKey:UIImagePickerControllerEditedImage];  
   [self performSelector:@selector(selectPic:) withObject:imageafterDelay:0.1];  
}  
 -(void)selectPic:(UIImage*)image  
{  
   NSLog(@"image%@",image);   
   imageView = [[UIImageView alloc] initWithImage:image];  
   imageView.frame = CGRectMake(0, 0, image.size.width, image.size.height);  
[self.viewaddSubview:imageView];  
   [self performSelectorInBackground:@selector(detect:) withObject:nil];  
}  
detect 为自己定义的方法,编辑选取照片后要实现的效果 取消选择:  -(void)imagePickerControllerDIdCancel:(UIImagePickerController*)picker  
 
{  
   [picker dismissModalViewControllerAnimated:YES];  
}  

 

对图库的操作

标签:

原文地址:http://www.cnblogs.com/Ganggang888/p/5253539.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!