I have xib file whose height can dynamically change as it contains labels of multiple lines. I need add this view as a subview of uiview that is defined in my view controller.
let settlementDetailsContentView = SettlementDetailsView.instanceFromNib(nibNamed: NibConstants.SettlementDetailsViewNib)
settlementDetailsContentView.frame = settlementDetailsView.bounds
settlementDetailsView.addSubview(settlementDetailsContentView)
Here settlementDetailsContentView contains the view that is designed in Interface builder. settlementDetailsView is the view defined in my view controller whose height constraint is greater or equal to zero.
Code below is the function that returns the view based on the nib name
class func instanceFromNib(nibNamed : String) -> SettlementDetailsView
{
return UINib(nibName: nibNamed, bundle: nil).instantiate(withOwner: nil, options: nil)[0] as! SettlementDetailsView
}
The problem with what I did is that view below the settlementdetailsview overlaps on this since the view height is not resizing based on the subview.
This is how the UI looks.Claim documents overlapping on settlementDetails view.
This is how the uiview should look like
settlementDetailsView.setNeedsLayout()
after addingsettlementDetailsContentView
as subview. - laxman khanalsettlementDetailsView
to true. Also verify if the frame ofsettlementDetailsView
changes - hfehrmann