iPhone : How to detect the end of slider drag?

后端 未结 16 2662
不思量自难忘°
不思量自难忘° 2020-12-02 07:36

How to detect the event when the user has ended the drag of a slider pointer?

16条回答
  •  悲&欢浪女
    2020-12-02 08:19

    Since UISlider is a subclass of UIControl, you can set a target and action for its UIControlEventTouchUpInside.

    If you want to do it in code, it looks like this:

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

    That will send you a dragEndedForSlider: message when the touch ends.

    If you want to do it in your nib, you can control-click your slider to get its connections menu, and then drag from the “Touch Up Inside” socket to the target object.

    You should also add a target and action for UIControlEventTouchUpOutside and for UIControlEventTouchCancel.

提交回复
热议问题