首页 文章

当UISlider一直拖到最后时会发生什么事件?

提问于
浏览
0

我的视图中有一个UISlider .

_seekBar = new UISlider
{
    MinValue = 0,
    Continuous = false,
    AutoresizingMask = UIViewAutoresizing.FlexibleWidth
};
_seekBar.TouchDown += OnTouchDown;
_seekBar.TouchDragInside += OnDragInside;
_seekBar.ValueChanged += OnValueChanged;

我按如下方式设置了三个事件 .

private void OnTouchDown(object sender, EventArgs e)
{
    // pause the watcher when you touch down
    _audioPlayerService.Pause();
}

private void OnDragInside(object sender, EventArgs e)
{
    // basically updates the number next to the slider as you drag
    _viewModel.CurrentPositionMsec = (int)_seekBar.Value;
}

private void OnValueChanged(object sender, EventArgs e)
{
    _viewModel.UserSeekPosition = (int)_seekBar.Value;

    if (_viewModel.SeekToCommand.CanExecute())
        _viewModel.SeekToCommand.Execute(_viewModel);

    _audioPlayerService.Start();
}

注意:观察者基本上观看音频播放器并报告进度 .

我遇到的问题是,如果我将滑块一直拖到末尾(最右边),即使没有释放任何东西,我也会开始变得奇怪 .

  • 尝试重新拖动并不会阻止观察者

  • 滑块开始在我的拇指位置和观察的当前进度之间跳跃 .

  • 音频断断续续并跳到曲目的末尾 .

除非我松开滑块,否则当我将拇指滑动到最后时,我不希望发生任何事情 .

注意:如果我不一直寻求到最后,一切都按预期完成

What event fires when a UISlider is dragged all the way to the end?

1 回答

  • 2

    “除非我松开滑块,否则当我将拇指滑到最后时,我不希望发生任何事情”

    做这个 . 触摸释放后才会触发 .

    _seekBar.continuous = NO;
    

相关问题