I have 3 sliders and I am trying to get the overall rating label to display the average of the three ..they are all working and are displaying the individual slider amount in their respected labels...I am fairly new to making custom methods but how would I grab all three of the label amounts, average them and then have the overall label continuously updating as new values are being produced on the sliders? I dont have any code to show for this at the moment
it's fairly easy: In the method that's called when any of the sliders' value changes you do the following:
- (IBAction)sliderChanged:(id)sender {
//individual values
float val1 = slider1.value;
float val2 = slider2.value;
float val3 = slider3.value;
//calculate the average
float avg = (val1 + val2 + val3) / 3.0f;
//display values
label1.text = [NSString stringWithFormat@"%f", val1];
label2.text = [NSString stringWithFormat@"%f", val2];
label3.text = [NSString stringWithFormat@"%f", val3];
labelAvg.text = [NSString stringWithFormat@"%f", avg];
}