KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What I want to do is set up a bunch of UIControl objects to send all events through the same handler. That handler than needs to determine what the appropriate action is based on the UIControlEvents type that triggered. - (void)handleEventFromControl:(id)sender withEvent:(UIEvent *)event { UIControl *control = sender; NSIndexPath *indexPath = [controlIndexPaths objectForKey:control]; UIControlEvents controlEventType = event.type; //PROBLEM HERE BOOL fire = NO; NSNumber *eventCheck = [registeredEventsByToolkitIndex objectAtIndex:indexPath.toolkit]; fire = ([eventCheck integerValue] & controlEventType); if(!fire) { eventCheck = [registeredEventsByControlIndex objectAtIndex:indexPath.control]; fire = ([eventCheck integerValue] & controlEventType); } if(!fire) { eventCheck = [registeredEventsByIndexPath objectForKey:indexPath]; fire = ([eventCheck integerValue] & controlEventType); } if(fire) { [self.delegate toolkit:self indexPath:indexPath firedEvent:event]; } } As best as I can tell, event.type doesn't work this way. I want to avoid having a subclass of UIControl because that is severe overkill for what I want to do. The rest of the moving parts here aren't really that important; what I want is a way to check against UIControlEvents after the target:action: pair is used in the following setup: - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents If there is a different way to setup of a target:action: that sends back the UIControlEvents , I'd take that. But I am not seeing it in the documentation. Or, at the very least, get access outside of the UIControl object such that I can get the type I want.
Tags (comma-separated)
Save Edits
Cancel