Reputation: 160
I have a custom view that subclasses UIView. It has a touchesEnded event, however it does not show up in Interface Builder (under Events). I want to some how get that method into my View Controller so a method fires whenever the touchesEnded fires. I'm considering using target Action, however,
The code below doesn't work because forControlEvents:UIControlEventTouchesEnded doesn't exist. So I don't know how I can get the touchesEnded method from my class that subclasses UIView.
[customView addTarget:self action:@selector(actionWithUIControlEvent:) forControlEvents:UIControlEventTouchUpInside];
Any help would be much appreciated!
Upvotes: 1
Views: 1150
Reputation:
Just let your view controller handling the event message. Implement the touchesEnded:withEvent:
method in it, and call the second.
Upvotes: 3
Reputation: 9169
From your view controller, you should be able create a UITapGestureRecognizer
on your custom view. You can check the state of the recognizer to see if you're receiving the message on touches ended: UIGestureRecognizerStateEnded
.
Upvotes: 2