Ios 如何在点击TableCell时移动滑动条
在不在Ios 如何在点击TableCell时移动滑动条,ios,objective-c,uitableview,slider,uislider,Ios,Objective C,Uitableview,Slider,Uislider,在不在didSelectRowAtIndexPath中创建单元格时,将滑块添加到单元格中: 下次还要更彻底地解释您的问题。是否只解释代码?没有一个解释?@Daniele94头衔算吗?@CrimsonChris不算。从技术上讲,这不是一个问题,因为它不包含“?”字符。这也不是正确的英语语法,对我(一个非母语人士)来说,他问的问题是不可理解的。@CrimsonChris:代码没有缩进。不是对问题的解释。只有一个请求被抛出。对不起,我不喜欢。不幸的是,我不能投反对票questions@Daniele9
didSelectRowAtIndexPath
中创建单元格时,将滑块添加到单元格中:
下次还要更彻底地解释您的问题。是否只解释代码?没有一个解释?@Daniele94头衔算吗?@CrimsonChris不算。从技术上讲,这不是一个问题,因为它不包含“?”字符。这也不是正确的英语语法,对我(一个非母语人士)来说,他问的问题是不可理解的。@CrimsonChris:代码没有缩进。不是对问题的解释。只有一个请求被抛出。对不起,我不喜欢。不幸的是,我不能投反对票questions@Daniele94-请将其标记为“不清楚您在问什么”。我已经这么做了。。。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//frame for the slider
CGRect myFrame = CGRectMake(60.0f, 10.0f, 250.0f, 25.0f);
//create and initialize the slider
mySlider = [[UISlider alloc] initWithFrame:myFrame];
//set the minimum value
self.mySlider.minimumValue = 0.0f;
//set the maximum value
self.mySlider.maximumValue = 100.0f;
//set the initial value
self.mySlider.value = 25.0f;
//set this to true if you want the changes in the sliders value
//to generate continuous update events
[self.mySlider setContinuous:true];
//attach action so that you can listen for changes in value
[self.mySlider addTarget:self action:@selector(getSliderValue:) forControlEvents:UIControlEventValueChanged];
//add the slider to the view
[selectedView addSubview:self.mySlider];
//move the origin for the Step Slider
myFrame.origin.y += myFrame.size.height + 20.0f;
self.myStepSlider = [[UISlider alloc] initWithFrame:myFrame];
self.myStepSlider.minimumValue = 0.0f;
self.myStepSlider.maximumValue = 100.0f;
self.myStepSlider.value = 30.0f;
[self.myStepSlider setContinuous:false];
[self.myStepSlider addTarget:self action:@selector(getSliderValue:) forControlEvents:UIControlEventValueChanged];
[selectedView addSubview:self.myStepSlider];
[cell.containter addSubview:selectedView];
}
- (void) getSliderValue:(UISlider *)paramSender{
//if this is my Step Slider then change the value
if ([paramSender isEqual:self.myStepSlider]){
float newValue = paramSender.value /10;
paramSender.value = floor(newValue) * 10;
}
NSLog(@"Current value of slider is %f", paramSender.value);
}