UICollectionView Xamarin.ios中的UILabel重叠

UICollectionView Xamarin.ios中的UILabel重叠,xamarin.ios,uilabel,overlap,Xamarin.ios,Uilabel,Overlap,我需要创建一个UICollectionView,其中包含在我的数据库中搜索的用户的配置文件。 UICollectionView必须包含UILabel和UIImage,名称和图像必须取自PHP。目前我两个都有,但当我进行新的搜索时,旧信息与新信息重叠,造成如下混乱效果: 我是在xamarin.ios上开发的,我附加了处理UILabel和UIImage元素的可视输出的代码部分 public void UpdateCell(string elemento) { img =

我需要创建一个UICollectionView,其中包含在我的数据库中搜索的用户的配置文件。 UICollectionView必须包含UILabel和UIImage,名称和图像必须取自PHP。目前我两个都有,但当我进行新的搜索时,旧信息与新信息重叠,造成如下混乱效果:

我是在xamarin.ios上开发的,我附加了处理UILabel和UIImage元素的可视输出的代码部分

 public void UpdateCell(string elemento)
    {
        img = new UIImageView(UIImage.FromBundle("ProfiloImgNotFound"));

        UILabel name = new UILabel { Text = elemento, TextColor = UIColor.SecondaryLabelColor, TextAlignment = UITextAlignment.Center };
        Console.WriteLine(name.Text);
        name.Font = UIFont.FromName(".AppleSystemUIFont", 20);
        
        var labelHeight = 20;
        var labelWidth = img.Bounds.Width;
        name.Frame = new CGRect(0, img.Bounds.Height + 10, labelWidth, labelHeight);
        AddSubviews(new UIView[] { img, name });
    }

在添加新的ImageView和标签之前,是否删除了旧的子视图?否,我认为新标签会覆盖旧标签,我该如何做?将BackgorundColor设置为白色。我尝试使用此选项,ContentView.BackgroundColor=UIColor.white;但是不行。添加多个子视图不是一个好的设计。您可以更新ImageView的标签文本和图像。