Uitableview 带有情节提要的自定义静态表格视图-单元格背景
我正在使用故事板来创建一个很棒的静态桌面视图。 一切都很好 现在我想自定义表视图单元格 因此,我添加了一个tableViewController并将其连接到情节提要视图。 以下是我用于自定义的代码:Uitableview 带有情节提要的自定义静态表格视图-单元格背景,uitableview,storyboard,customization,Uitableview,Storyboard,Customization,我正在使用故事板来创建一个很棒的静态桌面视图。 一切都很好 现在我想自定义表视图单元格 因此,我添加了一个tableViewController并将其连接到情节提要视图。 以下是我用于自定义的代码: -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
UIColor *color = [[UIColor alloc] initWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
cell.detailTextLabel.backgroundColor = color;
cell.textLabel.backgroundColor = color;
cell.backgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cellbackground.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0]];
cell.selectedBackgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cellbackground_down.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0]];
return cell;
}
但是如果我现在运行应用程序,表视图是空的,没有自定义背景
有人能帮我吗?:=)
Laurenz有两种方法可以为您的
表格视图设置单元格:静态
单元格和动态原型。事实上,对于静态单元模式,您可以直接在IB中设置单元的背景色
如果要使用cellforrowatinexpath
方法自定义单元格,则应实现所有非可选方法,如:numberOfRowsInSection
cellforrowatinexpath