alberto garcia
alberto garcia

Reputation: 35

fire event when touch up inside uiview and outside button

I have a view overlayed to the iPhone's camera view. In this view I have some uibuttons that are displayed in positions depending of values from accelerometer/compass. I need to fire an event when the user touch up inside the view but he doesn't touch up inside the uibuttons, I mean, the opposite action of touch up inside the uibuttons. Anyone knows a kind to do this? Thanks!

Upvotes: 2

Views: 4197

Answers (3)

alberto garcia
alberto garcia

Reputation: 35

I tried your options but it doesn't work. The view that I tried to fire the event was in a TabBar item in a camera view, so I think the responders chain doesn't work with it. Finally, I solved the problem doing the overlay view the first responder with:[viewOverlay.view becomeFirstResponder];

Upvotes: 0

heximal
heximal

Reputation: 10517

you may e.g. assign one event handler (IBAction) to UiVeiw and its UIButtons and then compare sender parameter:

-(IBAction) viewClicked :(id) sender {
  if (id == myView) ...
}

Upvotes: 0

John Parker
John Parker

Reputation: 54435

If you implement the UIResponder touchesBegan:withEvent: method..

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

...on your view, you'll be able to tell when the user has pressed outside of the buttons.

See the UIResponder Class Reference for more information.

Upvotes: 1

Related Questions