- UIImagePickerController想必是个很常用的控件,在使用中发现,pickerController默认创建出来同时可以拍摄照片或者是拍摄视频,如下:
UIImagePickerController *systemImagePicker = [[UIImagePickerController alloc]init];
systemImagePicker.delegate = self;
systemImagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
systemImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:systemImagePicker animated:YES completion:nil];
- 如只需要拍照模式,不用设置mediaTypes即可。
UIImagePickerController *systemImagePicker = [[UIImagePickerController alloc]init];
systemImagePicker.delegate = self;
//systemImagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
systemImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
systemImagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;//设置摄像头捕获类型
[self presentViewController:systemImagePicker animated:YES completion:nil];
转载一篇文章,关于UIImagePickerController讲的很全,作为记录:
UIImagePickerController
网友评论