ios - UILayoutConstraint creates constraints that go offscreen -


my tableview cell 3 labels , uistepper if text in first label long moves other views on making stepper go off screen. here constraints:

[self.contentview addconstraints:[nslayoutconstraint constraintswithvisualformat:@"h:|-15-[name(>=price@750)]-[price(==60)]-[quantity(==20)]-[stepper]-15-|"                                                                          options:0                                                                          metrics:nil                                                                            views:views]]; [self.contentview addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:|-[name]-|"                                                                          options:0                                                                          metrics:nil                                                                            views:views]]; [self.contentview addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:|-[price]-|"                                                                          options:0                                                                          metrics:nil                                                                            views:views]]; [self.contentview addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:|-[quantity]-|"                                                                          options:0                                                                          metrics:nil                                                                            views:views]]; [self.contentview addconstraint:[nslayoutconstraint constraintwithitem:self.stepper                                                              attribute:nslayoutattributecentery                                                              relatedby:0                                                                 toitem:self.quantity                                                              attribute:nslayoutattributecentery                                                             multiplier:1.0f                                                               constant:0.0f]]; 

my labels creation is:

uilabel* label = [uilabel new]; label.translatesautoresizingmaskintoconstraints = no; label.adjustsfontsizetofitwidth = yes; [label setminimumscalefactor:0.5f]; [self.contentview addsubview:label]; return label; 

the fontsize defaulted 17. if have following text stepper gets pushed offscreen instead of font shrinking.

cell.name.text = @"this label"; cell.price.text = @"puddle"; cell.quantity.text = @"ha"; 

id post picture dont have enough reputation points. acts content view bigger real screen width , pushes stepper off screen.

you need add compression resistance priority label. such as:

[self.name setcontentcompressionresistancepriority:uilayoutprioritydefaultlow foraxis:uilayoutconstraintaxishorizontal];


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -