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

Create new constraint IBOutlet doesn't works. #20

Open
wtlucky opened this issue Jun 16, 2016 · 4 comments
Open

Create new constraint IBOutlet doesn't works. #20

wtlucky opened this issue Jun 16, 2016 · 4 comments

Comments

@wtlucky
Copy link

wtlucky commented Jun 16, 2016

You need upgrade a new version.

@yuhanle
Copy link

yuhanle commented Jul 15, 2016

我也遇到了这个问题

@MrBoog
Copy link

MrBoog commented Jul 27, 2016

嗯,要改些东西,不过最后我还是没有使用这个库,第一层布局改用代码来写了。希望以后苹果能支持xib嵌套使用

@yuhanle
Copy link

yuhanle commented Jul 28, 2016

恩 希望如此

@erlangzhang
Copy link

erlangzhang commented Jan 11, 2017

if (placeholderView.constraints.count > 0) {
  for (NSLayoutConstraint* constraint in placeholderView.constraints) {
    if ([UIDevice currentDevice].systemVersion.floatValue < 10) {
      if (constraint.firstItem == placeholderView) {
        [constraint setValue:realView forKey:@"firstItem"];
      }
      if (constraint.secondItem == placeholderView) {
        [constraint setValue:realView forKey:@"secondItem"];
      }
    } else {
      Ivar referenceItem =
      class_getInstanceVariable(NSLayoutAnchor.class, "_referenceItem");
      id firstAnchorItem = object_getIvar(
                                          [constraint valueForKey:@"firstAnchor"], referenceItem);
      if (firstAnchorItem == placeholderView) {
        object_setIvar([constraint valueForKey:@"firstAnchor"], referenceItem,
                       realView);
      }
      if ([constraint valueForKey:@"secondAnchor"] != nil) {
        id secondAnchorItem = object_getIvar(
                                             [constraint valueForKey:@"secondAnchor"], referenceItem);
        if (secondAnchorItem == placeholderView) {
          object_setIvar([constraint valueForKey:@"secondAnchor"],
                         referenceItem, realView);
        }
      }
    }
  }
  [realView addConstraints:placeholderView.constraints];
}

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

No branches or pull requests

4 participants