我有以下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");
}
答案 0 :(得分:2)
当点击时,您已经告诉按钮拨打takePhotoButton:
。尝试添加
[takePhotoButton addTarget:self action:@selector(takePhotoButton:) forControlEvents:UIControlEventTouchUpInside];
在initWithFrame: