gpt4 book ai didi

ios - 选择单元格或滚动时 UITableView 上的 UIImage 移动

转载 作者:行者123 更新时间:2023-11-29 02:56:48 26 4
gpt4 key购买 nike

我向 UITableView 提供了来自 JSON 的名称和图像列表。 “SDWebImage”处理图像下载。除了当用户选择一行或滚动表格 View 时图像向左移动之外,它工作正常。

显示问题的两个屏幕截图。

Initial aspect

After selection

界面生成器设置 IB

实现非常标准:

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil ) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];

}
cell.textLabel.text = [[array objectAtIndex:indexPath.row]objectForKey:@"marca"];
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;

[cell.imageView setImageWithURL:[NSURL URLWithString:[[array objectAtIndex:indexPath.row]objectForKey:@"photoUrl"]]placeholderImage:[UIImage imageNamed:@"placeholder.png"] ];
return cell;
}

我该怎么做才能停止图像移动?

最佳答案

我刚刚在一个应用程序上遇到了类似的问题,发现这是因为我重新使用了 UITableViewCells 默认的 imageView IBOutlet。

在我创建了一个新的 IBOutlet 之后,调用了 imageView 以外的东西,并将其连接起来解决了问题。

关于ios - 选择单元格或滚动时 UITableView 上的 UIImage 移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23782106/

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