cameraOverlayView上的按钮无法正常工作

时间:2013-12-16 01:41:18

标签: ios objective-c ipad camera-overlay

我有以下cameraOverlayView在某种程度上有效。调用UIImagePickerController时,不显示标准控件,'拍照'按钮和 logo.jpg ObViewControllerCameraOverlay <中所述显示/ strong>即可。该按钮的功能在于按下它时会变为蓝色但我的问题是它不会调用该动作(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");
}

1 个答案:

答案 0 :(得分:2)

当点击时,您已经告诉按钮拨打takePhotoButton:。尝试添加

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

initWithFrame:

中创建按钮后