My goal is define my own cell style, with background, font and size. I try this.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ScreenListElements *currentScreenElement = [self.screenDefBuild.elementsToTableView objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:currentScreenElement.objectName];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:currentScreenElement.objectName];
}
cell.textLabel.text = currentScreenElement.objectName;
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.contentView.backgroundColor = [UIColor blackColor];
}
I would like to change cell backgrond, but my app doesn't enter to willDisplayCell method. I have declared my class as:
@interface MyTableView : UIViewController <UITableViewDataSource,NSCopying> {
}
Should i have something else? Or maybe is a better way to declare own cell style.
@interface MyTableView : UIViewController <UITableViewDataSource, UITableViewDelegate ,NSCopying> {
}
the method
tableView:willDisplayCell:forRowAtIndexPath
is delegate method of UITableView
EDITED (to make it correct & accepted answer)
setting delegate
[myTableView setDelegate:self];