У меня есть подкласс TableViewController и метод initWithStyle, например:
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
[self.view setFrame:CGRectMake(0, 200, 320, 280)];
}
return self;
}
Я хочу добавить фоновое изображение для каждого моего TableViewCell, и изображение отображается, но оно просто отображает часть изображения (мой размер изображения 320 × 48), мой код:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.imageView.image = [UIImage imageNamed:@"cell_bg_light.png"];
return cell;
}
и результат:
![enter image description here](https://i.stack.imgur.com/n4XqD.jpg)