Scrollview上的UISlider - Iphone

时间:2013-09-18 06:41:41

标签: iphone objective-c

我在我的viewcontroller上添加了一个自定义滑块到我的滚动视图但添加后我无法滚动。我在这里看了类似的问题,但是

scrollview.canCancelContentTouches=NO;    

无效。有什么建议?谢谢。

滑块代码:

 CGRect frame = CGRectMake(20, 12.0, 280.0, 480);
_customSlider = [[UISlider alloc] initWithFrame:frame];
[_customSlider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
_customSlider.backgroundColor = [UIColor clearColor];
UIImage *stetchLeftTrack = [[UIImage imageNamed:@"orangeslide.png"]
                            stretchableImageWithLeftCapWidth:2.0 topCapHeight:0.0];
UIImage *stetchRightTrack = [[UIImage imageNamed:@"slider.png"]
                             stretchableImageWithLeftCapWidth:2.0 topCapHeight:0.0];

   [_customSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
[_customSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];

_customSlider.minimumValue = 0.0;
_customSlider.maximumValue = 10.0;
_customSlider.continuous = YES;
_customSlider.value = 50.0;

[ _scrollview addSubview:_customSlider];

1 个答案:

答案 0 :(得分:1)

您需要检测何时使用滑块并停止使用滚动视图。

我认为this answer可以提供帮助