简体   繁体   English

带有覆盖的iOS 7 UIImagePickerController - 重新拍摄并使用不可用的照片

[英]iOS 7 UIImagePickerController with Overlay - retake and use photo not usable

Even though I set userInteractionsEnabled to NO and my overlayframe is cleary not overlapping the buttons, I cannot click them. 即使我将userInteractionsEnabled设置为NO并且我的overlayframe是清晰的而不是按钮重叠,我也无法点击它们。

截图

Code: 码:

    // Init Picker
    UIImagePickerController* picker = [[UIImagePickerController alloc] init];

    //Create camera overlay for square pictures
    CGFloat navigationBarHeight = picker.navigationBar.bounds.size.height + 25;
    CGFloat height = picker.view.bounds.size.height - 2 * navigationBarHeight;
    CGFloat width = picker.view.bounds.size.width;
    CGRect f = CGRectMake(0, navigationBarHeight, width, height);
    CGFloat barHeight = (f.size.height - f.size.width) / 2;
    UIGraphicsBeginImageContext(f.size);
    [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.7] set];
    UIRectFillUsingBlendMode(CGRectMake(0, 0, f.size.width, barHeight), kCGBlendModeNormal);
    UIRectFillUsingBlendMode(CGRectMake(0, f.size.height - barHeight, f.size.width, barHeight - 4), kCGBlendModeNormal);
    UIImage *overlayImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageView *overlayIV = [[UIImageView alloc] initWithFrame:f];

    // Disable all user interaction on overlay
    [overlayIV setUserInteractionEnabled:NO];
    [overlayIV setExclusiveTouch:NO];
    [overlayIV setMultipleTouchEnabled:NO];

    // Map generated image to overlay
    overlayIV.image = overlayImage;

    // Present Picker
    picker.modalPresentationStyle = UIModalPresentationCurrentContext;
    picker.delegate = self;
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) {
        picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
    }
    [picker.cameraOverlayView addSubview:overlayIV];

    [self presentViewController:picker animated:YES completion:nil];

Any ideas? 有任何想法吗?

change this: [picker.cameraOverlayView addSubview:overlayIV]; 改变这个: [picker.cameraOverlayView addSubview:overlayIV];

to: [picker setCameraOverlayView:overlayIV]; to: [picker setCameraOverlayView:overlayIV];

i had the same problem, but my solution was slightly different. 我有同样的问题,但我的解决方案略有不同。 i was using xib files and the appropriate views and buttons were indeed in the correct hierarchy. 我正在使用xib文件,相应的视图和按钮确实在正确的层次结构中。

but i had to dynamically create a temporary view after the main parent view loaded (viewDidLoad) and add this temp view as the camera overlay. 但是我必须在加载主父视图(viewDidLoad)后动态创建临时视图,并将此临时视图添加为相机覆盖。 then i added the buttons as a subview to this temp view. 然后我将按钮作为子视图添加到此临时视图中。

 - (void)viewDidLoad
 {
   ImgPicker = [[UIImagePickerController alloc] init]; 

   if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

    // note: need to set a manually created view (vOverlay) as the image picker overlay,
    //  and then add the button controls (vControls) to this manually created vOverlay.
    //  Otherwise, the buttons in vControls are not clickable
     UIView *tempView = [[UIView alloc] initWithFrame:ImgPicker.view.frame];
     [tempView addSubview:self.vButtons];

     ImgPicker.cameraOverlayView = tempView;
    }
 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UIImagePickerController 使用照片/重拍按钮不起作用 - UIImagePickerController Use Photo / Retake buttons don't work UIImagePickerController - 自定义叠加(Swift)上的重新启动按钮 - UIImagePickerController - Retake button on custom Overlay (Swift) 如何在不移动使用照片和在iOS中重拍的情况下应用相机功能? - How to apply camera feature without moving to use photo and retake in iOS? 在iOS应用中拍照后是否可以避免“使用”/“重拍”屏幕? - Is it possible to avoid the “use”/“retake” screen after taking a photo in an iOS app? UIImagePickerController在UpperCase Letters“USE_PHOTO”,“RETAKE”和Gallery Images“CAMERA_ROLL”中显示文本? - UIImagePickerController shows text in UpperCase Letters “USE_PHOTO” , “RETAKE” and Gallery Images “CAMERA_ROLL”? Swift:如何更改UIImagePickerController的“使用照片”,“取消”,“拍摄”,“重拍”按钮的默认行为 - Swift: how to change default behaviour of buttons “Use Photo”, “Cancel”, “Shoot”, “Retake” of UIImagePickerController 禁用重拍,播放和使用视频屏幕UIImagePickerController - Disable the retake, play and use video screen UIImagePickerController 相机“重拍”和“使用照片”按钮不起作用 - Camera " Retake " and " Use photo " buttons not working 使用UIImagePickerController自定义“使用”,“取消”,“重拍”和“倒车”按钮事件 - Custom “Use”, “Cancel”,“Retake” and “Reverse Camera” button event using UIImagePickerController UIImagePickerController自定义叠加层预览拍摄的照片 - UIImagePickerController custom overlay preview taken photo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM