XXNibBridge icon indicating copy to clipboard operation
XXNibBridge copied to clipboard

Create new constraint IBOutlet doesn't works.

Open wtlucky opened this issue 8 years ago • 4 comments

You need upgrade a new version.

wtlucky avatar Jun 16 '16 12:06 wtlucky

我也遇到了这个问题

yuhanle avatar Jul 15 '16 07:07 yuhanle

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

MrBoog avatar Jul 27 '16 13:07 MrBoog

恩 希望如此

yuhanle avatar Jul 28 '16 02:07 yuhanle

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];
}

erlangzhang avatar Jan 11 '17 10:01 erlangzhang