0

次のような単純なカスタム UICellView を使用しています。

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIColor* color = [UIColor colorWithRed:204/255.0f green:62/255.0f blue:56/255.0f alpha:1.0f];

        // Initialization code
        //Styling the cell:
        UIView* spacer = [[UIView alloc] initWithFrame:CGRectMake(40,200, 350, 100)];
        [spacer setBackgroundColor:[UIColor colorWithRed:180/255.0f green:56/255.0f blue:61/255.0f alpha:1.0f]];
        //
        UIView* BlockNumber = [[UIView alloc] initWithFrame:CGRectMake(40,200, 179, 175)];
        [BlockNumber setBackgroundColor:[UIColor whiteColor]];

        [self.contentView addSubview:spacer];
        [self.contentView addSubview:BlockNumber];

        //

        self.backgroundColor=color;
    }



    return self;
}

forループでセルのサブビューをチェックしようとしましたが、セルビュー内には表示されませんが、そこにあるようです。ただし、self.backgroundColor は実際には色を変更しますが、ビューを追加するとうまくいきません。

どんな助けでも大歓迎です。

4

1 に答える 1

0

セルビューの下にビューを追加しているようです。交換してみる

CGRectMake(40,200, 350, 100)

CGRectMake(40, 0, 350, 100)
于 2013-10-23T19:02:41.030 に答える