swift - How to get resizing tableView cell with different content without deleting constraints in iOS -


i have tableview cell different content(views, labels, imageviews) in 1 cell. in cells content can not full. how can use resizing cells without removing , adding constraints? thanks.

illustration of problem

one of possible solutions problem:

  1. add constraints hidden state priority 1000
  2. add constraints resized state lower priority (ex 750)
  3. save constraints only hidden state iboutlet collection
  4. save constraints only resized state iboutlet collection

code:

@iboutlet var hiddenconstraints: [nslayoutconstraint] = [] @iboutlet var visibleconstraints: [nslayoutconstraint] = []  func hide(_ hide: bool) {      hiddenconstraint in self.hiddenconstraints {         hiddenconstraint.isactive = hide     }      visibleconstraint in self.visibleconstraints {         visibleconstraint.isactive = !hide     }      self.layoutifneeded() } 

there faster solution:

  1. move content can hidden container view
  2. set height constraint container view
  3. change code height constraint constant 0 if hidden or proper height if visible

code:

@iboutlet var heightconstraint: nslayoutconstraint!  func hide(_ hide: bool) {      self. heightconstraint.constant = hide ? 0 : 150  //estimated height      self.layoutifneeded() } 

this not approach, lead constraint crashes @ runtime. prefer use first one.

also need update cell table move other cells or down.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -