Sunday, 15 September 2013

iphone - NSGenericException', reason: 'Unable to install constraint on view -



iphone - NSGenericException', reason: 'Unable to install constraint on view -

terminating app due uncaught exception 'nsgenericexception', reason: 'unable install constraint on view. constraint reference outside subtree of view? that's illegal. constraint: view:; layer = ; contentoffset: {0, 0}>'

you need install constraint on "higher" of 2 views. good, general way this:

nslayoutconstraint* constraint = ...; nsview* firstview = constraint.firstitem; nsview* secondview = constraint.seconditem; [[firstview ancestorsharedwithview: secondview] addconstraint: constraint];

just word of caution: it's remember here constraint attributes evaluated in context of view on added. instance, value of nslayoutattributeleft of viewa, constraint installed on viewb, interpreted in coordinate space of viewb. constraints reference sibling views or superview, fact largely irrelevant, there's no restriction constraints can't reference 2 views aren't siblings or direct parents.

iphone objective-c ios6 xcode4.5

No comments:

Post a Comment