カスタムUITableViewCellクラスを持つグループ化されたUITableViewがあり、各セルにカスタム背景画像を追加しています。ただし、これを行うと、セルの区切り文字が表示されません。テーブルスタイルをグループ化ではなくプレーンに切り替えるだけで、セパレータが表示されます。
グループ化されたテーブルが必要です-セパレータを表示するにはどうすればよいですか?
これが私のコードです:
@interface MyCustomTableViewCell : UITableViewCell
@end
@implementation MyCustomTableViewCell
// because I'm loading the cell from a xib file
- (id)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self)
{
// Create a background image view.
self.backgroundView = [[UIImageView alloc] init];
}
return self;
}
// MyViewController
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//
// standard cell dequeue + create cell code here
//
//
// Configure the cell background now
//
UIImage *backgroundImage = [UIImage imageNamed:@"odd_row.png"];
if (indexPath.row % 2 == 0)
{
backgroundImage = [UIImage imageNamed:@"even_row.png"];
}
UIImageView *backgroundView = (UIImageView *)cell.backgroundView;
backgroundView.image = backgroundImage;
}