iOS 系统相机长按拍照问题
来源:互联网 发布:各国劳动效率数据 编辑:程序博客网 时间:2024/05/21 11:33
最近在调用系统相机上传图片,发现拍照只能长按才可以,google了许多都没发现有遇到过的.自己排查了好长时间.发现是自己项目中的问题.
这是正常的代码:
项目中重写了一个button 的类别 ,导致拍照时的Button事件出现问题.把button类别去掉或者修改就可以了
pragma mark 使用相机 begain
//相机 begain
-(void)selectHeadimage{
[self takePhotoChoice];
}
- (void)takePhotoChoice {
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@”取消” destructiveButtonTitle:nil otherButtonTitles: @”拍照”, @”相册选择”,nil];
[myActionSheet showInView:[UIApplication sharedApplication].keyWindow];
}
// 调用相机
- (void)takePhoto {
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.allowsEditing = YES;
picker.delegate = self;
picker.allowsEditing=YES;//允许编辑
picker.sourceType = sourceType;
[self presentViewController:picker animated:YES completion:^{}];}else{ Log(@"无法打开照相机,请在真机中使用");}
}
// 调用相册
- (void)LocalPhoto {
//选择相册图片 修改状态栏颜色UIImagePickerController *ipc = [[UIImagePickerController alloc] init];ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;//修改状态栏颜色UIView* statusView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 20)];statusView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"顶部背景"]];[ipc.view addSubview:statusView];ipc.delegate = self;ipc.allowsEditing = YES;[self presentViewController:ipc animated:YES completion:^{}];
}
pragma mark - UINavigationControllerDelegate
-(void)navigationController:(UINavigationController )navigationController willShowViewController:(UIViewController )viewController animated:(BOOL)animated {
//调相册时 控制状态栏if ([navigationController isKindOfClass:[UIImagePickerController class]] && ((UIImagePickerController *)navigationController).sourceType == UIImagePickerControllerSourceTypePhotoLibrary) { for (UINavigationItem *item in navigationController.navigationBar.subviews) { if ([item isKindOfClass:[UIButton class]]&&([item.title isEqualToString:@"取消"]||[item.title isEqualToString:@"Cancel"])){ UIButton *button = (UIButton *)item; [button setEnabled:YES]; [button setHidden:NO]; } }}[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];[navigationController.navigationBar setTintColor:[UIColor whiteColor]];
}
pragma mark - UIActionSheetDelegate 选择相机or相册事件
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0:
[self takePhoto];
break;
case 1:
[self LocalPhoto];
break;
}
}
pragma mark - UIImagePickerControllerDelegate
(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:^{}];
}
pragma mark 相机使用 end
- iOS 系统相机长按拍照问题
- 系统相机拍照剪辑问题
- Swift iOS 8调用系统相机的拍照
- iOS 学习日志:调用相机拍照获得图片旋转问题
- iOS10 调用系统相机拍照后黑屏的问题
- Android7.0调用系统相机拍照、访问相册问题。
- Android7.0 6.0 相机拍照,系统裁剪适配问题
- Android7.0调用系统相机拍照、访问相册问题。
- android之系统相机拍照
- android 调用系统相机拍照
- android调用系统相机拍照
- android调用系统相机拍照
- 调用系统相机进行拍照
- Android调用系统相机拍照
- Android 调用系统相机拍照
- Android 调用系统相机拍照
- 调用系统相机拍照功能
- Android:Button同时设置OnLongClick、OnClick模拟相机长按聚焦 短按拍照的功能
- 画虚线
- ListView之ArrayAdapter
- php中的几个常用的魔术常量
- iOS单例详解
- 算法学习(二) 贪婪算法
- iOS 系统相机长按拍照问题
- L1-007. 念数字
- Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)
- Android 事件处理的理解
- c++之容器适配器
- LitePal使用总结
- 数据块写函数fwrite
- iOS一分钟搞定加入购物车的交互动画【转】
- 7. Reverse Integer (转置整数)