I am using segmented controls and a slider on a view. In most cases, a default value of the control is appearing in a text box when the view controller is first accessed. (These are all created by code, not IB (based on Apple's UICatalog code). But in two cases they are left blank.
In the ViewDidLoad section, I have the following methods that work well except the default value does not appear. I don't know what syntax to use. Can you help?
Thanks,
Steve
For the slider:
For the segmented control with three buttons (buttons contain images):
In the ViewDidLoad section, I have the following methods that work well except the default value does not appear. I don't know what syntax to use. Can you help?
Thanks,
Steve
For the slider:
Code:
- (void)sliderActionRideHeight:(id)sender{
if (labelRideHeight.text) // Don't know how to word this line correctly
{
NSArray *arrayRideHeight = [NSArray arrayWithObjects: @"15.0", @"15.5", @"16.0", @"16.5", @"17.0", @"17.5", nil];
NSString *labelValueRideHeight;
labelValueRideHeight = [arrayRideHeight objectAtIndex:(int)sliderRideHeight.value]; // To link slider value to object in array and echo to label.
labelRideHeight.text = [NSString stringWithFormat:@"%@mm", labelValueRideHeight]; // from a forum post reply
}
else { labelRideHeight.text = [NSString stringWithFormat:@"%@mm", 25.0]; } // Default value. Does not work
}
For the segmented control with three buttons (buttons contain images):
Code:
- (void)segmentAction:(id)sender
{
switch ([((UISegmentedControl *)sender) selectedSegmentIndex])
{
case 0:
labelBumpSteer.text = @"0 washers";
break;
case 1:
labelBumpSteer.text = @"1 washer";
break;
case 2:
labelBumpSteer.text = @"2 washers";
break;
default:
labelBumpSteer.text = @"0 washers"; // Default value. Does not work.
break;
}
return;
}