View height constraints are not set correctly as I scroll UICollectionView up and down

前端 未结 2 1316
青春惊慌失措
青春惊慌失措 2021-01-23 19:14

I\'m trying to decide view heights based on a model property, but as UICollectionView is scrolled up and down, incorrect heights are assigned to visible cells. It s

2条回答
  •  时光取名叫无心
    2021-01-23 20:09

    Here's the fix for this as recommended by Xamarin support:

    NSLayoutConstraint heightConstraint;
    public void UpdateHeight(int height)
    {
        if (heightConstraint == null)
        {
            heightConstraint = _uiView.HeightAnchor.ConstraintEqualTo(height);
            heightConstraint.Active = true;
        }
        else
        {
            heightConstraint.Constant = height;
        }
    }
    

提交回复
热议问题