我使用Slider控件而不是使用Scrollviewer Vertical Bar。 但它运作不正常。
scrollViewer.contentSize = CGSizeMake(320, (ThumbnailSizeHeight + PADDING) * [list count]);
slider.maximumValue = (ThumbnailSizeHeight + PADDING) * [list count];
请指正。
答案 0 :(得分:0)
在contentSize
大于滚动查看器的帧大小之前,您不需要滚动。所以,
CGFloat scrollableHeight = (ThumbnailSizeHeight + PADDING) * [list count] - scrollViewer.frame.size.height;
if ( scrollableHeight <= 0 ) {
slider.enabled = NO; // or use the `hidden` property
} else {
slider.enabled = YES; // or .hidden based on what you do in `if`
slider.maximumValue = scrollableHeight;
}
稍后在UIControlEventValueChanged
,
- (IBAction)sliderValueChanged:(UISlider *)slider {
scrollViewer.contentOffset = CGPointMake(0, slider.value);
}