Reputation: 63
Currently I have a UISlider that is linked to the ScrollView. Once I drag the slider it moves the scrollview.
However the ScrollView doesn't move the slider
Any Ideas on how I can sync the both would be much appreciated
Thanks in Advance.
Upvotes: 3
Views: 1105
Reputation: 4901
try this code
slider.minimumValue = 0.0;
slider.maximumValue =ScrollView.contentSize.height;
set content offset for ScrollView
-(void)sliderAction:(id)sender
{
UISlider * slider = (UISlider*)sender;
ScrollView.contentOffset=CGPointMake(0,[slider value]);
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
slider.value=scrollView.contentOffset.y
}
Upvotes: 1
Reputation: 7850
It's not clear what you mean with "ScrollView doesn't move the slider". Do you want to change slider's value? Or do you want to change slider's position?
If you want to change slider's value according to scroll view's content offset, implement scrollViewDidScroll:
method in delegate of your scroll view and set slider's value there.
Upvotes: 2