问题
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!!
回答1:
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...
回答2:
Just OR
them:
[self.button addTarget:self action:@selector(selector0:) forControlEvents:(UIControlEventTouchUpInside|UIControlEventTouchUpOutside)];
来源:https://stackoverflow.com/questions/12101108/uiresponder-and-multiple-uicontrolevents