UIImagePickerController的简单使用
来源:互联网 发布:手机阿里云 编辑:程序博客网 时间:2024/05/17 09:26
#pragma mark 当点击修改头像按钮的时候,触发的方法- (IBAction)modifyUserPic:(UIButton *)sender{ myActionSheet = [[UIActionSheetalloc]initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"打开相机",@"从相册中选择",nil]; [myActionSheet showInView:self.view]; }#pragma mark - UIActionSheetDelegate- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ switch (buttonIndex) { case 0: [self takePhoto];//打开相机 break; case 1: [self loadPhoto];//打开本地相册 break; }}//开始拍照-(void)takePhoto{ UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { UIImagePickerController *picker = [[UIImagePickerControlleralloc]init]; picker.delegate = self; picker.allowsEditing = YES; picker.sourceType = sourceType; [self presentViewController:picker animated:YEScompletion:nil]; } else { UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"无法打开相机,请在真机中调试!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show]; } }//打开本地相册-(void)loadPhoto{ UIImagePickerController *picker = [[UIImagePickerControlleralloc]init]; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; picker.delegate = self; picker.allowsEditing = YES; [selfpresentViewController:picker animated:YES completion:^{}]; }#pragma mark - UIImagePickerControllerDelegate- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ _userPicImageView.image = [info objectForKey:UIImagePickerControllerEditedImage]; [picker dismissViewControllerAnimated:YES completion:nil]; }
0 0
- UIImagePickerController的简单使用
- 关于UIImagePickerController的简单使用
- UIImagePickerController简单使用
- UIImagePickerController简单使用
- UIImagePickerController 的简单实用
- UIImagePickerController的简单应用
- UIImagePickerController的简化使用
- UIImagePickerController的使用
- UIImagePickerController的详细使用
- UIImagePickerController的使用
- UIAlertController和UIImagePickerController的使用
- 使用UIImagePickerController
- UIImagePickerController使用
- UIImagePickerController使用
- UIImagePickerController使用
- UIImagePickerController使用
- UIImagePickerController使用
- UIImagePickerController使用
- Joomla里如何获取文章的完整URL地址
- 法国海关
- 1076. Forwards on Weibo (30)
- [Android] Android开发优化之——对Bitmap的内存优化
- 【Boost】boost库asio详解1——strand与io_service区别
- UIImagePickerController的简单使用
- Apache -poi
- 虚拟机VMvare 上跑 X86 OpenWRT
- CentOS 修改IP地址, DNS, 网关
- 从上往下遍历二元树
- HDU3681Prison Break(状态压缩+BFS)
- ssh 免密码登陆
- 数据挖掘笔记-聚类-SpectralClustering-原理与简单实现
- 一步一步打造Geek风格的技术博客