我想創建一個自定義UITableViewCell
它應該有一個不同於默認實現的外觀。爲此我分類了UITableViewCell
並且想要添加標籤,文本框和背景圖片。只有背景圖像似乎不會出現。 也許我完全在這裏錯誤的軌道上,也許子類化UITableViewCell
畢竟是一個壞主意,是否有任何理由爲什麼會是這種情況,有沒有更好的辦法?自定義一個UITableViewCell子類
總之這是我嘗試過,在子類中的initWithStyle
我把以下內容:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self == nil)
{
return nil;
}
UIImage *rowBackground;
backRowImage = [UIImage imageNamed:@"backRow.png"];
((UIImageView *)self.backgroundView).image = backRowImage;
}
我在做什麼錯在這裏?我應該在drawRect
方法中設置背景圖像嗎?