UILabel overlap in UICollectionView Xamarin.ios


I needed to create a UICollectionView containing the profiles of users searched in my database.
The UICollectionView must contain a UILabel and a UIImage, the name and image must be taken from PHP. I currently get both, but when I go to do a new search, the old information overlaps the new, creating a confusing effect like this:

enter image description here

I am developing on xamarin.ios, I am attaching the portion of code that deals with the visual output of the UILabel and UIImage elements.

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

        UILabel name = new UILabel { Text = elemento, TextColor = UIColor.SecondaryLabelColor, TextAlignment = UITextAlignment.Center };
        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 });

Source: Xamarin.ios Questions

Categorised as Uncategorised Tagged , ,


Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us