I’m trying to create a UISlider in code, it’s fairly simple what I’m doing:
self.slider = [[UISlider alloc] initWithFrame:CGRectMake(66.0, 15.0, 235.0, 23.0)];
self.slider.minimumValue = 0.0;
self.slider.maximumValue = 100.0;
self.slider.continuous = YES;
self.slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:self.slider];
That code goes in my viewDidLoad method and that’s pretty much all I need, but the slider will not appear when my view is shown. Tried calling setNeedsDisplay on the view as well and it didn’t work.
If you’re creating your slider in code, then you shouldn’t have an IBOutlet to it, and the declaration should be strong (it’s probably being deallocated, since you only have a weak reference).