开发者

fire event when touch up inside uiview and outside button

开发者 https://www.devze.com 2023-01-31 23:27 出处:网络
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 v开发者_如何学Goalues from accelerometer/compass.

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 v开发者_如何学Goalues 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!


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.


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) ...
}


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];

0

精彩评论

暂无评论...
验证码 换一张
取 消