UIActionSheet的使用和系统相机的相关调用
来源:互联网 发布:2g和3g网络标志的区别 编辑:程序博客网 时间:2024/05/16 06:35
#pragma mark ------ 调用系统相机 ------
- (IBAction)cameraButton:(id)sender {
UIActionSheet *actionSheet = [[UIActionSheetalloc] initWithTitle:nildelegate:selfcancelButtonTitle:@"取消"destructiveButtonTitle:@"照相机"otherButtonTitles:@"图片库",@"闪光灯",nil];//UIActionSheet初始化,并设置delegate
actionSheet.actionSheetStyle =UIActionSheetStyleDefault;
[actionSheet showFromRect:self.view.boundsinView:self.viewanimated:YES];// actionSheet弹出位置
}
#pragma mark -UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 0:
{
NSLog(@"打开系统照相机");
if ([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *picker = [[UIImagePickerControlleralloc] init];
picker.delegate =self;//设置UIImagePickerController的代理,同时要遵循UIImagePickerControllerDelegate,UINavigationControllerDelegate协议
picker.allowsEditing =YES;//设置拍照之后图片是否可编辑,如果设置成可编辑的话会在代理方法返回的字典里面多一些键值。PS:如果在调用相机的时候允许照片可编辑,那么用户能编辑的照片的位置并不包括边角。
picker.sourceType =UIImagePickerControllerSourceTypeCamera;//UIImagePicker选择器的类型,UIImagePickerControllerSourceTypeCamera调用系统相机
[selfpresentViewController:picker animated:YEScompletion:nil];
}
else{
//如果当前设备没有摄像头
UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:nilmessage:@"哎呀,当前设备没有摄像头。" delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil];
[alertViewshow];
}
break;
}
case 1:
{
NSLog(@"打开系统图片库");
if ([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController * picker = [[UIImagePickerControlleralloc]init];
picker.delegate =self;
picker.allowsEditing =YES;//是否可以对原图进行编辑
//打开相册选择照片
picker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
[selfpresentViewController:picker animated:YEScompletion:nil];
}
else{
UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:nilmessage:@"图片库不可用" delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil];
[alertViewshow];
}
break;
}
case 2:
{
NSLog(@"调用系统闪关灯");
if ([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
device = [AVCaptureDevicedefaultDeviceWithMediaType:AVMediaTypeVideo];// 返回用于捕获视频数据的设备(摄像头)
if (![devicehasTorch]) {
NSLog(@"没有闪光灯");
}else{
[devicelockForConfiguration:nil];// 请求独占设备的硬件性能
if (device.torchMode ==AVCaptureTorchModeOff) {
[devicesetTorchMode: AVCaptureTorchModeOn];// 打开闪光灯
}
}
}
else
{
//如果当前设备没有摄像头
UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:nilmessage:@"哎呀,当前设备没有摄像头。" delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil];
[alertViewshow];
}
break;
}
case 3:
{
NSLog(@"取消");
break;
}
default:
break;
}
}
- UIActionSheet的使用和系统相机的相关调用
- iOS-UIActionSheet的简单使用和调用系统相簿
- iOS-UIActionSheet的简单使用和调用系统相簿
- UIAction的使用和调用系统相册和相机
- 调用系统的相机
- 调用系统的相机
- 调用系统的相机
- 调用系统的相机和相册
- Maltab相机的调用和使用
- 调用系统的图库和系统相机完成获取头像功能 包括popupWindow的使用
- ios系统相机的调用
- 调用系统相机的方式
- iOS 系统相机的调用
- Android开发 调用系统相机和加载图片到本地的使用
- Android 调用系统相机进行拍照 使用自带的图片选择器和裁剪工具
- 调用系统相机和图库册得到图片的例子
- iOS调用系统相机和相册的详细用法
- UIAlertView提示控件和UIActionSheet的使用
- sed -i "s/大小多少/日月水火/g" `grep 大小多少 -rl ./`
- Object-c 归档
- Jakarta Commons 读取xml配置
- Base64 编码原理
- globaldef.h
- UIActionSheet的使用和系统相机的相关调用
- eclipse从数据库逆向生成Hibernate实体类(eclipse中反向生成hibernate实体类+jpa注释)
- uva 10158 War(并查集的简单应用)
- Java Code Review清单
- Glib简介
- HEVC核心编码技术之六.环路滤波,SAO及其它
- i.MX6核心板
- VC++: LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- PHP 以编译方式安装,编译参数详解析!