ios - Checking whether a NSLayoutConstraint has been applied or not -


i have uitextview subclass has height constraint priority 500. other constraints in view it's inserted in have 1000 priority, therefore when constraints can't satisfied 1 one gets dropped.

i want able verify if dropped or not in order enable scrolling in case.

i tried verify way:

- (void)updateconstraints { cgsize size = [self sizethatfits:cgsizemake(self.bounds.size.width, flt_max)];  if (!heightconstraint) {     heightconstraint = [nslayoutconstraint constraintwithitem:self attribute:nslayoutattributeheight relatedby:nslayoutrelationequal toitem:nil attribute:0 multiplier:1.0f constant:size.height];     heightconstraint.priority=500;     [self addconstraint:heightconstraint]; } else heightconstraint.constant=size.height; [super updateconstraints];  if (self.bounds.size.height!=heightconstraint.constant) {     self.scrollenabled=yes; }      } 

thank you.

this way think layout calls/callbacks order:

  • [self.view layoutifneeded] <-- constraint calculated/applied immediately
  • [self.view setneedsupdateconstraints] <-- bottom-up, measure/calc; invokes updateconstraints
  • [self.view setneedslayout] <-- top-down, applies solutions constraints
  • [self.view setneedsdisplay] <-- top-down, render screen

sounds want implement - (void)updateconstraints on view, , add logging , debugging there. make sure call [super updateconstraints], or you're going have bad time. time method exits, constraints have been calculated.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -