I want one UIButton work like this: click it firstly, run start_method; click it secondly, run stop_method; click it thirdly run start_method again; click it fourthly, run stop_method again. Such a loop.
when i set the button :
[button addTarget:self action:@selector(start_method:) forControlEvents:UIControlEventTouchDown];
[button addTarget:self action:@selector(stop_method:) forControlEvents:UIControlEventTouchDownRepeat];
it responses both actions whenever you click it.
Any suggestions?
Add a boolean to your view controller, and set it to false. Then when you press the button, check the value of the boolean, and flip it, and run either the start or stop method.