我有下面的cameraOverlayView在一定程度上起作用。当调用UIImagePickerController时,标准控件将不显示,'Take Photo'按钮和logo.jpg将显示为在中描述的按钮在按下时会变蓝,但我的问题是它不调用操作( 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");
}发布于 2013-12-16 01:50:59
它看起来不像你告诉你的按钮,打电话给takePhotoButton:时,它被点击。试着添加
[takePhotoButton addTarget:self action:@selector(takePhotoButton:) forControlEvents:UIControlEventTouchUpInside];在initWithFrame:中创建按钮之后
https://stackoverflow.com/questions/20602197
复制相似问题