Reputation: 9243
Is there a way to call a selector for multiple UIControlEvents?
this doesn't work, but itl'll give u an idea of what i'm trying to do.
[self.slider addTarget:self action:@selector(sliderDidStopDragging:) forControlEvents:UIControlEventTouchUpInside, UIControlEventTouchUpOutside];
thanks!!
Upvotes: 3
Views: 1926
Reputation: 101
They are now an option set so you can use for: [.touchUpInside, .touchUpOutide]
Upvotes: 2
Reputation: 86137
Just OR
them:
[self.button addTarget:self action:@selector(selector0:) forControlEvents:(UIControlEventTouchUpInside|UIControlEventTouchUpOutside)];
Upvotes: 16
Reputation: 24041
try this way instead:
// same selector for different events
[self.button addTarget:self action:@selector(selector0:) forControlEvents:UIControlEventTouchUpInside];
[self.button addTarget:self action:@selector(selector0:) forControlEvents:UIControlEventTouchUpOutside];
// etc...
or you can use this one:
// different selectors for same event
[self.button addTarget:self action:@selector(selector1:) forControlEvents:UIControlEventTouchUpInside];
[self.button addTarget:self action:@selector(selector2:) forControlEvents:UIControlEventTouchUpInside];
// etc...
Upvotes: 1