私の目標は、背景、フォント、サイズを使用して、独自のセルスタイルを定義することです。これやってみます。
- (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];
}
セルの背景を変更したいのですが、アプリがwillDisplayCellメソッドに入りません。私は自分のクラスを次のように宣言しました:
@interface MyTableView : UIViewController <UITableViewDataSource,NSCopying> {
}
他に何かあるべきですか?または、独自のセルスタイルを宣言するためのより良い方法かもしれません。