1

カスタム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; 
}
4

1 に答える 1

1

セルにsubViewを指定すると、セパレータが自動的に非表示になります。したがって、画像自体に区切り線を追加してみてください。だからそれはあなたにセパレーターの外観を与えるでしょう。

ではごきげんよう。

于 2012-09-07T18:48:22.807 に答える