views:

22

answers:

1

I would like to know how to create a UISlider at runtime.

+1  A: 

You can add a slider like ever other view:

UISlider *slider = [[[UISlider alloc] initWithFrame:CGRectMake(50, 50, 100, 40)] autorelease];
[slider addTarget:self action:@selector(controlValueChanged:) forControlEvents:UIControlEventValueChanged];
slider.minimumValue = 100.00;
slider.maximumValue = 1000.00;
slider.continuous = YES;
[self.view addSubview:slider];

Use a frame that suits your needs, and add to the appropriate view (I used self.view in this example). Feel free to configure as needed. ;-)

Eiko