UIResponder和多个UIControlEvents
有没有办法为多个UIControlEvents调用select器?
这不起作用,但它会让你知道我在做什么。
[self.slider addTarget:self action:@selector(sliderDidStopDragging:) forControlEvents:UIControlEventTouchUpInside, UIControlEventTouchUpOutside];
谢谢!!
试试这个方法:
// same selector for different events [self.button addTarget:self action:@selector(selector0:) forControlEvents:UIControlEventTouchUpInside]; [self.button addTarget:self action:@selector(selector0:) forControlEvents:UIControlEventTouchUpOutside]; // etc...
或者你可以使用这个:
// different selectors for same event [self.button addTarget:self action:@selector(selector1:) forControlEvents:UIControlEventTouchUpInside]; [self.button addTarget:self action:@selector(selector2:) forControlEvents:UIControlEventTouchUpInside]; // etc...
只是OR
他们:
[self.button addTarget:self action:@selector(selector0:) forControlEvents:(UIControlEventTouchUpInside|UIControlEventTouchUpOutside)];