objective c - Animating a subview with CentreY constraint -


i have uitableviewcell 2 uilabels , uiswitch. labels multilined , placed on top of each other. uiswitch centred vertically. when turn off switch hide 1 of labels , height of row changes. causes switch jump though call:

[self.tableview reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic]; 

here tableviewcell class implementation:

 - (void)setbounds:(cgrect)bounds {   [super setbounds:bounds];    self.contentview.frame = self.bounds; }  - (void)setupview{      self.numberlabel.text = [nsstring stringwithformat:@"quote number %ld",    [self.celldata[@"rownumber"] integervalue]];     [self.controlswitch seton:[self.celldata[@"checked"] boolvalue]];      [uiview animatewithduration:0.5 animations:^{     if ([self.controlswitch ison]) {         self.quotelabel.text = self.celldata[@"quote"];         self.quotelabel.hidden = no;         self.bottomconst.constant = 10;     }else{         self.quotelabel.text = @"";         self.quotelabel.hidden = yes;         self.bottomconst.constant = 0;     }  }];   }  - (void)layoutsubviews {   [super layoutsubviews];    self.selectionstyle = uitableviewcellselectionstylenone;   [self.contentview updateconstraintsifneeded];   [self.contentview layoutifneeded];    self.numberlabel.preferredmaxlayoutwidth = cgrectgetwidth(self.numberlabel.frame);   self.quotelabel.preferredmaxlayoutwidth = cgrectgetwidth(self.quotelabel.frame); }   - (ibaction)removequote:(id)sender {    [self.delegate updatecell:self]; } 

the constraint settings on uitableviewcell looks this.

enter image description here

when switch turned on, i'm unhide quote label , set text. here link on how looks like. default behavior or there way can control movement of switch when row animates?

try this:

... [self.contentview updateconstraintsifneeded];  [uiview beginanimations:nil context:nil]; [self.contentview layoutifneeded]; [uiview commitanimations]; ... 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -