UISlider's editingDidEnd event is not working in iPad

亡梦爱人 提交于 2019-12-24 03:42:49

问题


I want to trigger one method when sliding the UISlider is ended.I used "editingDidEnd"event of UISlider in xib and attached it to a IBAction method but the method is not being called.Can any one please help me how to know when sliding is ended on UISlider?


回答1:


UISlider inherits from UIControl so you should be able to add and action on "UIControlEventTouchUpInside"

Try something like :

[slider addTarget:self action:@selector(sliderTouchUpInsideAction:) forControlEvents:UIControlEventTouchUpInside];

Hope this helps, Vincent




回答2:


You can attach to the "UIControlEventValueChanged" slider event instead and use the following code in your event handler:

  [slider addTarget:self action:@selector(handleValueChanged:event:) forControlEvents:UIControlEventValueChanged];

- (void)handleValueChanged:(id)sender event:(id)event {
     UITouch *touchEvent = [[event allTouches] anyObject]; // there's only one touch
     if (touchEvent.phase == UITouchPhaseEnded) { /* place your code here */ }}


来源:https://stackoverflow.com/questions/5855542/uisliders-editingdidend-event-is-not-working-in-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!