ios - Collapse Expand UITableView -


i tried expand/collapse uitableview inside uiviewcontroller. put uitableview height constraint 0 , make animation

func collapseexpandroomsection() {      isroomcollapsed = !isroomcollapsed      tableheightconstraint.constant = isroomcollapsed ? 0.0 : totaltableheight          uiview.animatewithduration(0.3) {         self.view.layoutifneeded()      }  } 

the collapse effect works fine when tried expand table cells gone.

thanks

look have updated constraint, should doing in order believe:

self.view.setneedsupdateconstraints() self.view.setneedslayout() self.view.layoutifneeded() 

as have updated constraint, therefore should firstly update set update constraints , set needs layout. followed layoutifneeded() have change apply immediately.

as discussed briefly on comments, code applicable if override updateconstraint. not correct in answering question above.


Comments

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -