objective c - iOS 9 constraint error -


this code:

[self.collectionview settranslatesautoresizingmaskintoconstraints: no];  [self.view addconstraint:[nslayoutconstraint constraintwithitem:self.collectionview                                                       attribute:nslayoutattributetop                                                       relatedby:nslayoutrelationequal                                                          toitem:self.toplayoutguide                                                       attribute:nslayoutattributetop                                                      multiplier:1.0f                                                        constant:1.0f]];  [self.view addconstraint:[nslayoutconstraint constraintwithitem:self.collectionview                                                       attribute:nslayoutattributebottom                                                       relatedby:nslayoutrelationequal                                                          toitem:self.bottomlayoutguide                                                       attribute:nslayoutattributebottom                                                      multiplier:1.0f                                                         constant:0.f]];  [self.view addconstraint:[nslayoutconstraint constraintwithitem:self.collectionview                                                        attribute:nslayoutattributeleading                                                        relatedby:nslayoutrelationequal                                                           toitem:self.view                                                       attribute:nslayoutattributeleading                                                      multiplier:1.0f                                                        constant:0.0f]];  [self.view addconstraint:[nslayoutconstraint constraintwithitem:self.collectionview                                                       attribute:nslayoutattributetrailing                                                        relatedby:nslayoutrelationequal                                                           toitem:self.view                                                       attribute:nslayoutattributeright                                                      multiplier:1.0f                                                         constant:0.0f]]; 

work's fine on ios 8 , ios7 when ios9 when run app error :

terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** +[nslayoutconstraint constraintwithitem:attribute:relatedby:toitem:attribute:multiplier:constant:]: constraint cannot made between leading/trailing attribute , right/left attribute. use leading/trailing both or neither.'

when remove constraints app works fine. need know what's problem , have been changed ios8 ios9.

your log suggest that...either can use leading/trailing or right/left not both ...

so change 4th constraint below

[self.view addconstraint:[nslayoutconstraint constraintwithitem:self.collectionview                                                   attribute:nslayoutattributetrailing                                                    relatedby:nslayoutrelationequal                                                       toitem:self.view                                                   attribute:nslayoutattributetrailing                                                  multiplier:1.0f                                                     constant:0.0f]];  

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -