gpt4 book ai didi

iphone - 所有单元格的UITableViewCell BackgroundImage

转载 作者:行者123 更新时间:2023-12-01 18:23:00 25 4
gpt4 key购买 nike

我在下面的代码中将UITableViewCell的所有背景图像设置为相同的模式:

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SelectAnAlbumTableViewCellBackground"]] autorelease];
}

起作用,除了任何空单元格。我想知道如何设置所有 UITableViewCell的背景,而不仅是其中包含数据的背景?

最佳答案

问题是方法`

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

仅针对非空单元格被调用。

所以你可以用这种方法增加细胞数量
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

当您在单元格中添加数据时,可以添加标签或所需内容,但是当您在空单元格中时,您什么也不做。

关于iphone - 所有单元格的UITableViewCell BackgroundImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16139189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com