如何在更改滑块值时自动滚动视图
我想通过滑块控制滚动条,因此当用户滑动滑块滚动条时也应该滚动视图。
I want to control scroll bar by slider so when user slides the slider scroll bar should also scroll the view.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的滑块被声明为“slider”并且滚动视图被声明为“scrollView”:
现在创建一个方法
- (void)sliderChanged:(id)sender
。它应该使用slider.value
获取滑块的值,确定将滚动视图(应该可见的CGRect
)滚动到的位置,然后[scrollViewscrollRectToVisible:动画:]
Assuming your slider is declared as 'slider' and the scroll view is declared as 'scrollView':
Now create a method
- (void)sliderChanged:(id)sender
. It should get the slider's value withslider.value
, determine where to scroll your scroll view (aCGRect
that should be visible) to and then[scrollView scrollRectToVisible:animated:]