iPhone UISlider not visible
- by John Qualis
I want to add a UISlider to my app programmatically without using the IB.
I am adding a UISlider to my UIViewController using the code below. However I don't see the slider when the view comes up. What am I missing? I am using iPhone SDK 3.1.2.
Appreciate any help.
@synthesize slider;
....
- (void)viewDidLoad {
...
...
slider = [[UISlider alloc] initWithFrame: CGRectMake(0, 480 - 80, 300, 20)];
slider.minimumValue = 0.0;
slider.maximumValue = 100.0;
slider.tag = 0;
slider.value = 50;
slider.continuous = YES;
slider.enabled = YES;
[slider addTarget:selfaction:@selector(handleSlider:)forControlEvents:UIControlEventValueChanged];
self.view addSubview:slider];
In the .h file
...
UISlider *slider;
...
@property (nonatomic, retain) UISlider *slider;
- (void) handleSlider:(id)sender;