I created a custom UITableViewCell in Interface Builder (Storyboard) and imported it into my project via #import CustomTableViewCell.h .
Everything works fine, but the cell loads only in the selected state.

I want the cell to be loaded into each row using init.
PS Slider and text fields work fine. I also made all IB connections.
CustomTableViewCell.m
#import "CustomTableViewCell.h" @implementation CustomTableViewCell @synthesize sliderLabel, slider; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code } return self; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (IBAction)getSliderValuesWithValue:(UISlider *)sender { sliderLabel.text = [NSString stringWithFormat:@"%i / 100", (int) roundf(sender.value)]; } @end
Further Code
- (CustomTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Kriterium"; CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } // Configure the cell... cell.textLabel.text = [NSString stringWithFormat:@"%@", [listOfItems objectAtIndex:indexPath.row]]; return cell; }
PS If I add some buttons, etc. Programmatically in this method, it works. But I want to create rows in IB. There must be a solution.
ios xcode uitableview
Das
source share