UIImagePickerController 拍照
来源:互联网 发布:云计算系统软件 编辑:程序博客网 时间:2024/05/14 13:27
@interface TestAlertViewController ()<UIActionSheetDelegate,UIImagePickerControllerDelegate, UINavigationControllerDelegate>
@property (nonatomic,strong )IBOutlet UIImageView *phonoImage;
@property (nonatomic,strong )UIImagePickerController *imagePikerViewController;
@end
@implementation TestAlertViewController
- (void)viewDidLoad {
[superviewDidLoad];
self.imagePikerViewController = [[UIImagePickerControlleralloc]init];
self.imagePikerViewController.delegate =self;
self.phonoImage.contentMode = UIViewContentModeScaleAspectFit;
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
UIImage *image = info[UIImagePickerControllerEditedImage];
if (!image) {
image = info[UIImagePickerControllerOriginalImage];
}
self.phonoImage.image = image;
[selfdismissViewControllerAnimated:YEScompletion:NULL];
}
-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[selfdismissViewControllerAnimated:YEScompletion:NULL];
}
- (IBAction)alertButton:(UIButton *)sender {
UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:nilmessage:nilpreferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertActionactionWithTitle:@"拍照"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *_Nonnull action) {
//处理拍照
if ([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.imagePikerViewController.sourceType = UIImagePickerControllerSourceTypeCamera;
[selfpresentViewController:self.imagePikerViewControlleranimated:YEScompletion:NULL];
}
}]];
[alertController addAction:[UIAlertActionactionWithTitle:@"从相册中选取"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *_Nonnull action) {
//从相册中选取
if ([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
self.imagePikerViewController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[selfpresentViewController:self.imagePikerViewControlleranimated:YEScompletion:NULL];
}
}]];
[alertController addAction:[UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *_Nonnull action) {
}]];
[selfpresentViewController:alertController animated:YEScompletion:nil];
}
- UIImagePickerController 拍照
- UIImagePickerController 拍照
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照 时间长
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- UIImagePickerController拍照与摄像
- iOS-UIImagePickerController拍照与摄像
- iOS 拍照和摄像UIImagePickerController
- iOS 拍照和摄像UIImagePickerController
- WebView
- [Cool Node.js] Node.js简介
- 一个简单的学生登陆系统的jsp实现之登陆身份验证
- EditText入门
- SparkSQL入门_1
- UIImagePickerController 拍照
- Android开发---测试教程
- linux下安装mysql
- Firefox下打开wap站的表单,第一次页面正常,提交后验证失败,重新回到表单页乱码是什么原因造成的
- ozzie配置和example
- Android简单用属性动画实现两个控件重叠
- Yum配置文件详解
- 关于序列旋转(辗转相除求取最大公约数)
- Ruby 安装