I follow the code of user2207904
on viewDidLoad I create 20 sliders and 20 labels
then my 20 labels take the values of my faders (label.text= [NSString stringWithFormat:@"%i", slvalue];)
but like this if I move my labels don't follows my faders values...
how can I do to my labels follows my faders values?
MY CODE
- (void)viewDidLoad
{
[super viewDidLoad];
for(int i=0; i< 20; i++){
//sliders
UISlider *slider = [[[UISlider alloc] initWithFrame:CGRectMake(1+i*50, 450, 300, 10)] autorelease];
slider.minimumValue = 1;
slider.maximumValue = 100;
slider.continuous = YES;
[self.view addSubview:slider];
slider.transform = CGAffineTransformRotate(slider.transform, 270.0/180*M_PI);
[slider setThumbImage:thumbImage0 forState:UIControlStateNormal];
[slider release];
// label
UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(1+i*50, 640, 40, 15)];
int slvalue = slider.value;
label.text= [NSString stringWithFormat:@"%i", slvalue];
[self.view addSubview:label];
[label release];
}
New issue :
mofified
I do this :
i put an IBAction in my FirstViewController.m
- (IBAction)sliderUpdate:(UISlider *)sender {
self.label.text = [NSString stringWithFormat:@"%g", sender.value];
}
and put this in my viewDidLoad (FirstViewController.m)
{
[super viewDidLoad];
for(int i=0; i< 20; i++){
//sliders
UISlider *slider = [[[UISlider alloc] initWithFrame:CGRectMake(1+i*50, 450, 300, 10)] autorelease];
slider.minimumValue = 1;
slider.maximumValue = 100;
slider.continuous = YES;
[slider addTarget:self action:@selector(sliderUpdate:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:slider];
slider.transform = CGAffineTransformRotate(slider.transform, 270.0/180*M_PI);
[slider setThumbImage:thumbImage0 forState:UIControlStateNormal];
[slider release];
// label
UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(1+i*50, 640, 40, 15)];
int slvalue = slider.value;
label.text= [NSString stringWithFormat:@"%i", slvalue];
[self.view addSubview:label];
[label release];
}
i have this error in my (IBAction)sliderUpdate: Property 'label' not found on object of type 'FirstViewController *'