Log in or register to post comments

UIButton in OverlayViewController

March 28, 2013 - 5:08am #1



I am using the ImageTargets sample as a base for my app. I have already added some labels as hints for the user. I would like to add 2 uibuttons to the ImageTargetsOverlayViewController and I had no problems with that. I have also added a target action when the buttons are pressed. Problem is, touches are not processed by this controller. I am aware that the touchesBegan methods are implemented in ARParentViewController and overriden in OverlayViewController to pass through to the parent, so I have commented them out. But I still do not receive touches in the ImageTargetsOverlayViewController. Why is that?

And isn't the ImageTargetsOverlayViewController the place to add UI elements to interact with? Why should one handle touches in its parent controller?

I am using the native iOS sdk, MacOS 10.7.5, xcode 4.3.3, ipod 4th gen, iOS 5.1.




UIButton in OverlayViewController

April 16, 2013 - 4:38am #5

No problem.

Glad I could help :)


UIButton in OverlayViewController

April 16, 2013 - 4:15am #4

It certainly feels embarassing to have missed that... Thank you very much for pointing it out to me.

Best regards,


UIButton in OverlayViewController

April 16, 2013 - 4:01am #3

In the OverlayViewController file have a look at the ViewDidLoad function:


- (void) loadView


    CGRect screenBounds = [[UIScreen mainScreen] bounds];

    optionsOverlayView = [[OverlayView alloc] initWithFrame: screenBounds];

    self.view = optionsOverlayView;


    // We're going to let the parent VC handle all interactions so disable any UI

    // Further on, we'll also implement a touch pass-through

    self.view.userInteractionEnabled = NO;



If you change the bottom line to 


    self.view.userInteractionEnabled = YES;

...it will start to receive touch events.





UIButton in OverlayViewController

April 15, 2013 - 5:03pm #2

I'd be interested in a reply to this as well. I need to put buttons, etc in the overlayView but figuring out how to properly handle user interactions in this case seems a little wonky.

Log in or register to post comments