gpt4 book ai didi

ios - cameraOverlayView 上的按钮不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:08:55 25 4
gpt4 key购买 nike

我有以下 cameraOverlayView 在一定程度上工作。当调用 UIImagePickerController 时,标准控件不会显示,'Take Photo' 按钮和 logo.jpg 中所述显示>ObViewControllerCameraOverlay。该按钮的功能在于按下时它会变蓝,但我的问题是它不会调用该操作(NSLog 仅用于测试目的)。谁能看出我可能做错了什么?

@implementation ObViewControllerCameraOverlay

- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame])
{
UIImage *logo = [UIImage imageNamed:@"logo.jpg"];
UIImageView *logoView = [[UIImageView alloc] initWithImage:logo];
logoView.frame = CGRectMake(0, 0, 240, 50);
[self addSubview:logoView];

UIButton *takePhotoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[takePhotoButton setTitle:@"Take photo" forState:UIControlStateNormal];
takePhotoButton.frame = CGRectMake(0, 330, 320, 40);
[self addSubview:takePhotoButton];
}
return self;
}

- (IBAction)takePhotoButton:(id)sender
{
NSLog(@"test");
}

最佳答案

您似乎没有告诉您的按钮在被点击时调用 takePhotoButton:。尝试添加

[takePhotoButton addTarget:self action:@selector(takePhotoButton:) forControlEvents:UIControlEventTouchUpInside];

initWithFrame: 中创建按钮后

关于ios - cameraOverlayView 上的按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20602197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com