Hello I have a slightly similar issue except that I have several labels and sprites after each others in my scrollview i.e.:
backgroundSprite //the one directly attached to the scrollview, size adjusted to itemSprite.Top and Label4.bottom
-- ItemSprite
-- titleBar1
-- Label1
-- titleBar2
-- Label2
-- TitleBar3
-- Label3
-- TitleBar4
-- Label4
the top position of each element is obtained from the bottom of the upper element, using the anchor system.
TitleBar have fixed sizes
Label values can be changed programmatically since they come from a data structure. So label heights are obtained by putting label's Overflow parameter to ResizeHeight and their bottomAnchor values to none.
First i thought that everything was ok but i eventually noticed that sometimes the height of one of my label doesn t adjust. Tried different variants of updatePosition, resetPosition, InvalidateBounds (not sure what the last one does) but can't figure out how to fix the bug.
Even stranger, when i m in editor mode with the interface playing and i go to the anchor system of the UILabel that didn t adjust well, just putting a value (without validating it) in the bottomAnchor absolute field will trigger the height update to the correct value. So there must be some update occurring here.
Latest of my numerous code attempts below where I reinitialize the labels from a data structure
public void init(Content content)
{
this.content = content;
this.scrollView.ResetPosition();
this.contentPictureSprite.spriteName = content.Id + ".icon"; //itemSprite
this.contentPictureSprite.keepAspectRatio = UIWidget.AspectRatioSource.Free;
this.contentPictureSprite.MakePixelPerfect();
float ar = (float)this.contentPictureSprite.width / (float)this.contentPictureSprite.height;
this.contentPictureSprite.aspectRatio = ar;
this.contentPictureSprite.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnWidth;
this.contentPictureSprite.leftAnchor.relative = 0f;
this.contentPictureSprite.leftAnchor.absolute = 0;
this.contentPictureSprite.rightAnchor.relative = 1f;
this.contentPictureSprite.rightAnchor.absolute = 0;
this.descriptionLabel.text = content.Description; // label1
this.scrollView.UpdatePosition();
this.characteristicsLabel.text = content.Characteristics; // label2
this.scrollView.UpdatePosition();
this.availabilityLabel.text = content.Availability; // label3
this.scrollView.UpdatePosition();
this.audienceLabel.text = content.Audience; // label4
this.scrollView.UpdatePosition();
/*this.scrollView.InvalidateBounds();
this.scrollView.ResetPosition();
this.scrollView.UpdatePosition();*/
}
I have attached a screenshot (left when the issue occurs, right when it automatically adjust once i enter a value in the bottomAnchor.absolute field)
Any idea what I am missing?