I'm working with vuforia augmented Reality app. I'm displaying a button in EAGLView. But the button is not responding to click event. I have to get screenshot of what augmenting in top of overlay while ImageTarget is detect. After image recognize the overlay content and button is displaying on top of overlay. But while clicking the button it's not responding to user event
EAGLView.h:
Display 3D object:
@interface Object3D : NSObject {
unsigned int numVertices;
const float *vertices;
const float *normals;
const float *texCoords;
unsigned int numIndices;
const unsigned short *indices;
Texture *texture;
}
@interface ImageTargetsEAGLView : UIView <UIGLViewProtocol> {
@private
UIButton *photo;
}
@property (nonatomic) BOOL takePhotoFlag;
EAGLView.mm :
- (id)initWithFrame:(CGRect)frame appSession:(SampleApplicationSession *) app
{
self = [super initWithFrame:frame];
if (self) {
takePhotoFlag = NO;
[self DisplayPhotoButton];
return self;
}
- (void)takePhoto
{
NSLog(@"button pressed");
takePhotoFlag = YES;
}
- (void)DisplayPhotoButton
{
UIImage *closeButtonImage = [UIImage imageNamed:@"button.png"];
// UIImage *closeButtonTappedImage = [UIImage imageNamed:@"button_close_pressed.png"];
CGRect aRect = CGRectMake(20,20,
closeButtonImage.size.width,
closeButtonImage.size.height);
photo = [UIButton buttonWithType:UIButtonTypeCustom];
photo.frame = aRect;
[photo setImage:closeButtonImage forState:UIControlStateNormal];
[photo addTarget:self action:@selector(takePhoto) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:photo];
}
- (BOOL)presentFramebuffer
{
if (takePhotoFlag)
{
[self glToUIImage];
takePhotoFlag = NO;
}
}
Code for displaying overlay:
- (void)targetFound:(NSNotification *)notification
{
dispatch_async(dispatch_get_main_queue(), ^{
self.targetOverlayView = [[[NSBundle mainBundle] loadNibNamed:@"targetOverlayView" owner:nil options:nil] objectAtIndex:0];
Book *aBook = [notification object];
[self.targetOverlayView setBook:aBook];
[booksDelegate setLastScannedBook:aBook];
[booksDelegate setOverlayLayer:self.targetOverlayView.layer];
[self.view addSubview:self.targetOverlayView];
}