gpt4 book ai didi

ios - UITableViewCell 中的 UICollectionView

转载 作者:行者123 更新时间:2023-11-28 20:49:33 25 4
gpt4 key购买 nike

我在 TableViewCell 中使用了 CollectionView。一切正常,并按预期显示。但是如果我非常快速地滚动 TableView,一个集合中的项目(我在 collectionView 中使用图像)替换为另一个集合中的项目(图像)并在 View 上覆盖它(在代码中的 Debug模式下工作正常,它只是显示它们)。

UITableView GetCell():

public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
var item = _view.Items[indexPath.Row];
var cell = (MyTableCell)tableView.DequeueReusableCell(“cell”);
cell.TextLabelView.Text = item.Title;
cell.YesButtonView.Hidden = item.IsCategory;
cell.NoButtonView.Hidden = item.IsCategory;
if (item.IsImagePoint)
{
cell.ImagesCollectionView.DataSource = new ItemsDataSource(item.Images, cell.ImagesCollectionView);
cell.ImagesCollectionView.Delegate = new ItemsDelegate(item, _view);
}
return cell;
}

UICollectionView GetCell():

public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
{
var cell = (ImageViewCell)_collectionView.DequeueReusableCell(new NSString(“ImageViewCell”), indexPath);
var image = _images[indexPath.Row];
var imagePath = image.ThumbnailPath;
if (!string.IsNullOrEmpty(imagePath))
{
cell.ImagePath = imagePath;
}
return cell;
}

最佳答案

swift 5将其添加到您的自定义 UITableViewCell 类中。

override func prepareForReuse() {

collectionView.dataSource = nil
collectionView.delegate = nil
collectionView.reloadData()

collectionView.dataSource = self
collectionView.delegate = self
}

关于ios - UITableViewCell 中的 UICollectionView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59289635/

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