【发布时间】:2014-05-19 14:05:49
【问题描述】:
- (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);
}
【问题讨论】:
-
只有代码?没有一种解释?
-
@Daniele94 标题算不算?
-
@CrimsonChris 不,它没有。从技术上讲,这不是问题,因为它不包含“?”特点。它也不是正确的英语语法,对我(非母语人士)来说,他在问什么是不可理解的。
-
@CrimsonChris:代码没有缩进。不是对问题的解释。只抛出一个请求。我不喜欢它对不起。我很遗憾我不能对问题投反对票
-
@Daniele94 - 请将其标记为“不清楚你在问什么”。我已经这样做了...
标签: ios objective-c uitableview slider uislider