UIImagePickerController如何隐藏翻盖相机按钮?

时间:2012-03-01 23:19:27

标签: objective-c camera uiimagepickercontroller

有没有办法在UIImagePickerController中隐藏翻盖相机按钮?

感谢阅读 !^ _ ^!

2 个答案:

答案 0 :(得分:6)

我最终使用UIImagePickerController的自定义子类来修复此(和其他)问题:

#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

答案 1 :(得分:3)

您应该能够在覆盖视图中创建一个空按钮,该按钮浮动在翻转相机按钮的顶部。我攻击下面的代码进行测试,它似乎工作。试一试。

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;