UISlider how to set the initial value

Posted by slim on Stack Overflow See other posts from Stack Overflow or by slim
Published on 2010-05-21T01:02:27Z Indexed on 2010/05/21 1:40 UTC
Read the original article Hit count: 326

Filed under:
|
|

I'm pretty new at this iphone dev stuff and i'm working on some existing code at a company. The uislider i'm trying to set the initial value on is actually in a UITableViewCell and is a custom control. I was thinking in the cell init

cell = (QuantitiesCell *)[self loadCellWithNibName:@"QuantitiesCell" forTableView:ltableView withStyle:UITableViewCellStyleDefault];

i could just call something like

((QuantitiesCell *)cell).value = 5;

The actual QuantitiesCell class has the member value and the following functions

-(void)initCell;{
    if (listOfValues == nil) {
        [self initListOfValues];
    }
    quantitiesSLider.maximumValue = [listOfValues count]-1;
    quantitiesSLider.minimumValue = 0;
    quantitiesSLider.value = self.value;
}

-(void)initListOfValues;{
    listOfValues = [[NSMutableArray alloc] initWithCapacity:10];
    int j =0;
    for (float i = minValue; i <= maxValue+increment; i=i+increment) {
        [listOfValues addObject:[NSNumber numberWithFloat: i]];
        if (i == value) {
            quantitiesSLider.value = j;
        }
        j++;
    }
}

like i said, i'm pretty new at this so if i need to post more of the code to show whats going to get help, let me know,

This slider always is defaulting to 1, the slider ranges usually from 1-10, and i want to set it to a specific value of the item i'm trying to edit.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uislider