gpt4 book ai didi

ios - UITableView 不显示图像

转载 作者:行者123 更新时间:2023-11-29 10:59:09 24 4
gpt4 key购买 nike

看来我的 tableview delegate 根本不会显示我的图像。该图像在我添加到 View Controller 的 UIImageView 上显示良好。如果这些信息有帮助,我正在使用 Interface Builder 中的表格 View 。

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView setDelegate:self];
[tableView setDataSource:self];
static NSString *CellIdentifier = @"Cell";


UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

cell.accessoryView = [[UIImageView alloc] initWithImage:myimage];

return cell;

最佳答案

尝试通过 interface builderviewDidLoad 方法设置委托(delegate)和数据源。

-(void)viewDidLoad{
self.tableView.delegate = self;
self.tableView.dataSource = self;
//...
}

此外,确保 myImage 对象不是 nil

如果我没记错的话,default 样式有一个 imageView 属性。尝试:

cell.imageView.image = [UIImage imageNamed:@"image.png"];

关于ios - UITableView 不显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16824888/

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