Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate why everything returns false for hasAmbiguousLayout #2

Open
plivesey opened this issue Jan 14, 2016 · 2 comments
Open

Investigate why everything returns false for hasAmbiguousLayout #2

plivesey opened this issue Jan 14, 2016 · 2 comments

Comments

@plivesey
Copy link
Contributor

See UnitTestViews.m

For unit testing, the test has yet to come up with a view which actually has ambiguous layout according to the OS. It always seems to return true.

Maybe looking up some examples from WWDC videos would give some good examples.

@plivesey
Copy link
Contributor Author

Here is some code which I think should produce an ambiguous layout:

NSDictionary *viewsDictionary = @{
                                  @"view1": view1,
                                  @"view2": view2
                                  };
[superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[view1]-|" options:0 metrics:nil views:viewsDictionary]];
[superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[view2]-|" options:0 metrics:nil views:viewsDictionary]];
[superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[view1]-[view2]-|" options:0 metrics:nil views:viewsDictionary]];
[superview addConstraint:[NSLayoutConstraint constraintWithItem:superview
                                                      attribute:NSLayoutAttributeWidth
                                                      relatedBy:NSLayoutRelationEqual
                                                         toItem:nil
                                                      attribute:NSLayoutAttributeNotAnAttribute
                                                     multiplier:1
                                                       constant:100]];
[superview addConstraint:[NSLayoutConstraint constraintWithItem:superview
                                                      attribute:NSLayoutAttributeHeight
                                                      relatedBy:NSLayoutRelationEqual
                                                         toItem:nil
                                                      attribute:NSLayoutAttributeNotAnAttribute
                                                     multiplier:1
                                                       constant:100]];

@plivesey
Copy link
Contributor Author

For others looking at this ticket, I have managed to reproduce ambiguous layout errors in another project. I haven't updated the unit tests in the library yet, but the check is still valid and useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant