开发者

how can I scroll the view automatically on changing slider value

开发者 https://www.devze.com 2023-02-13 02:22 出处:网络
I want to control sc开发者_开发百科roll bar by slider so when user slides the slider scroll bar should also scroll the view.Assuming your slider is declared as \'slider\' and the scroll view is declar

I want to control sc开发者_开发百科roll bar by slider so when user slides the slider scroll bar should also scroll the view.


Assuming your slider is declared as 'slider' and the scroll view is declared as 'scrollView':

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

Now create a method - (void)sliderChanged:(id)sender. It should get the slider's value with slider.value, determine where to scroll your scroll view (a CGRect that should be visible) to and then [scrollView scrollRectToVisible:animated:]

0

精彩评论

暂无评论...
验证码 换一张
取 消