Wednesday, 14 December 2011

CReating a Slider(UI Object) in table view Cell-iPhone

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   
    static NSString *CellIdentifier = @"Cell";
   
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
   
   
    theSlider =  [[[UISlider alloc] initWithFrame:CGRectMake(174,12,120,23)] autorelease];
    theSlider.maximumValue=99;
    theSlider.minimumValue=0;
    [cell addSubview:theSlider];
    cell.accessoryView = theSlider;   
   
    [(UISlider *)cell.accessoryView addTarget:self action:@selector(sliderValueChange:) forControlEvents:UIControlEventValueChanged];
    //[cell.contentView addSubview:[[sliders objectAtIndex:indexPath.section] objectForKey:@"Red"]];
    //[cell.contentView addSubview:[[UISlider objectAtIndex:indexPath.section] objectForKey:@"Red"]];
    // Configure the cell.
    //cell.textLabel.text=@"Hai";
   
   
    return cell;
}

- (void)sliderValueChange:(id)sender{
   
}

No comments:

Post a Comment