1
我正在尝试实现无拇指的垂直滑块,它会触动它的轨迹。我已经分类UISlider和一切顺利水平滑块,但是当我将滑块转换为垂直时,有奇怪的东西与坐标进行。可能有其他方法来实现这个?请给我正确的方向,谢谢!自定义垂直UISlider问题
我现在使用此代码为滑块:
@implementation MMTouchSlider
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self];
self.value = self.minimumValue + (self.maximumValue - self.minimumValue) * (touchLocation.x/self.frame.size.width);
[super touchesBegan:touches withEvent:event];
}
- (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value {
CGRect thumbRect = [super thumbRectForBounds:bounds trackRect:rect value:value];
return thumbRect;
}
@end
实际问题是什么?你也可以提供截图吗? – jtbandes
提供屏幕截图并不容易,因为这是触摸故障。滑块值不是我在轨道上点击的位置,就像那样。 –
您能否提供预期的触摸坐标和报告的实际触摸坐标?也许他们可能会含有一些关于开发的线索。 –