Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/netyouli/whc_photocamerachoicepicturedemo
iOS从相册和相机选择图片进行封装
https://github.com/netyouli/whc_photocamerachoicepicturedemo
Last synced: about 1 month ago
JSON representation
iOS从相册和相机选择图片进行封装
- Host: GitHub
- URL: https://github.com/netyouli/whc_photocamerachoicepicturedemo
- Owner: netyouli
- Created: 2015-07-30T08:53:42.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-30T05:14:04.000Z (about 9 years ago)
- Last Synced: 2023-03-01T16:55:58.390Z (almost 2 years ago)
- Language: Objective-C
- Size: 141 KB
- Stars: 19
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WHC_PhotoCameraChoicePictureDemo
## 作者:吴海超
## 联系qq:712641411##iOS从相册和相机选择图片进行封装,从相册支持选择多张和一张控制,集成使用简单方便,具体看demo使用集成方式。
##运行效果
![image](https://github.com/netyouli/WHC_PhotoCameraChoicePictureDemo/blob/master/WHC_PhotoCameraChoicePictureDemo/b.png)![image](https://github.com/netyouli/WHC_PhotoCameraChoicePictureDemo/blob/master/WHC_PhotoCameraChoicePictureDemo/a.jpg)
##接口使用实例
####Use Example
```objective-c
- (IBAction)clickButton:(UIButton *)sender{
switch (sender.tag) {
case 0:{//从相册选择一张
WHC_PictureListVC * vc = [WHC_PictureListVC new];
vc.delegate = self;
vc.choiceMorePicture = NO;
[self presentViewController:[[UINavigationController alloc]initWithRootViewController:vc] animated:YES completion:nil];
}
break;
case 1:{//从相册选择多张
WHC_PictureListVC * vc = [WHC_PictureListVC new];
vc.delegate = self;
vc.choiceMorePicture = YES;
[self presentViewController:[[UINavigationController alloc]initWithRootViewController:vc] animated:YES completion:nil];
}
break;
case 2:{//从相机选择
WHC_CameraVC * vc = [WHC_CameraVC new];
vc.delegate = self;
[self presentViewController:vc animated:YES completion:nil];
}
break;
default:
break;
}
}//下面是代理实现在代理里面显示所选图片
#pragma mark - WHC_ChoicePictureVCDelegate
- (void)WHCChoicePictureVC:(WHC_ChoicePictureVC *)choicePictureVC didSelectedPhotoArr:(NSArray *)photoArr{
for (UIView * subView in _imageSV.subviews) {
if([subView isKindOfClass:[UIImageView class]]){
[subView removeFromSuperview];
}
}
for (NSInteger i = 0; i < photoArr.count; i++) {
UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(i * CGRectGetWidth(_imageSV.frame), 0, CGRectGetWidth(_imageSV.frame), CGRectGetHeight(_imageSV.frame))];
imageView.image = photoArr[i];
[_imageSV addSubview:imageView];
}
_imageSV.contentSize = CGSizeMake(photoArr.count * CGRectGetWidth(_imageSV.frame), 0);
}#pragma mark - WHC_CameraVCDelegate
- (void)WHCCameraVC:(WHC_CameraVC *)cameraVC didSelectedPhoto:(UIImage *)photo{
[self WHCChoicePictureVC:nil didSelectedPhotoArr:@[photo]];
}```