Closed Forsarion closed 10 years ago
View doesn't added to view hierarchy. Therefore it can't specify superview in single constraint.
NSInvalidArgumentException: Unable to parse constraint format:
Unable to interpret '|' character, because the related view doesn't have a superview
|-50-[view1]-50-|
e.g.
[NSLayoutConstraint constraintWithItem:superview
attribute:NSLayoutAttributeLeft
relatedBy:NSLayoutRelationEqual
toItem:view1
attribute:NSLayoutAttributeLeft
multiplier:1.f
constant:50.f];
Sorry, haven't posted all code, view is actually added to superview.
The following code doesn't raise any exceptions
UIView* view3 = [UIView new];
UIView* container = [UIView new];
[container addSubview:view3];
NSArray* constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-50-[view3]-50-|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(view3)];
I don't see a scope of the following code. In the UI application it works fine without any exceptions. But when I'm trying to compile it during test it fails - that is actually the problem.
Views and superviews that are used for constraints should be block variables - they will not be realesed after "before" block fired.
Trying to test this one VFL:
Getting compile error: NSInvalidArgumentException: Unable to parse constraint format:
Still don't know why this happens.