UIImagePickerController how to hide the flip camera button?

三世轮回 提交于 2019-11-30 17:51:18

问题


is there a way to hide the flip camera button inside the UIImagePickerController?

thanks for reading !^_^!


回答1:


I ended up using a custom subclass of UIImagePickerController to fix this (and other) issues:

#import "SMImagePickerController.h"

@implementation SMImagePickerController

void hideFlipButtonInSubviews(UIView *view) {
    if ([[[view class] description] isEqualToString:@"CAMFlipButton"]) {
        [view setHidden:YES];
    } else {
        for (UIView *subview in [view subviews]) {
             hideFlipButtonInSubviews(subview);
        }    
    }    
}    

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    hideFlipButtonInSubviews(self.view);
}    

@end



回答2:


You should be able to create an empty button inside an overlayview that you float on top of the flip camera button. I hacked the code below to test and it seemed to work. Give it a try.

UIView *cameraOverlayView = [[UIView alloc] initWithFrame:CGRectMake(screenSize.width - 100.0f, 5.0f, 100.0f, 35.0f)];
[cameraOverlayView setBackgroundColor:[UIColor blackColor]];
UIButton *emptyBlackButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 35.0f)];
[emptyBlackButton setBackgroundColor:[UIColor blackColor]];
[emptyBlackButton setEnabled:YES];
[cameraOverlayView addSubview:emptyBlackButton];

cameraUI.allowsEditing = YES;
cameraUI.showsCameraControls = YES;
cameraUI.delegate = self;

cameraUI.cameraOverlayView = cameraOverlayView;


来源:https://stackoverflow.com/questions/9525736/uiimagepickercontroller-how-to-hide-the-flip-camera-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!