diff --git a/Source/ios/Storyboard/TyphoonViewHelpers.m b/Source/ios/Storyboard/TyphoonViewHelpers.m index 940c522c7..605a58094 100644 --- a/Source/ios/Storyboard/TyphoonViewHelpers.m +++ b/Source/ios/Storyboard/TyphoonViewHelpers.m @@ -43,9 +43,15 @@ + (void)transferPropertiesFromView:(UIView *)src toView:(UIView *)dst id firstItem = replaceFirstItem ? dst : constraint.firstItem; id secondItem = replaceSecondItem ? dst : constraint.secondItem; // Use the same constraint instance that the external outlets - [constraint setValue:firstItem forKey:NSStringFromSelector(@selector(firstItem))]; - [constraint setValue:secondItem forKey:NSStringFromSelector(@selector(secondItem))]; - [dst addConstraint:constraint]; + NSLayoutConstraint *newConstraint = [NSLayoutConstraint constraintWithItem:firstItem + attribute:constraint.firstAttribute + relatedBy:constraint.relation + toItem:secondItem + attribute:constraint.secondAttribute + multiplier:constraint.multiplier + constant:constraint.constant]; + newConstraint.priority = constraint.priority; + [dst addConstraint:newConstraint]; } dst.frame = src.frame; diff --git a/Tests/iOS/Storyboard/TyphoonViewHelpersTests.m b/Tests/iOS/Storyboard/TyphoonViewHelpersTests.m index 4af675c2f..b04839197 100644 --- a/Tests/iOS/Storyboard/TyphoonViewHelpersTests.m +++ b/Tests/iOS/Storyboard/TyphoonViewHelpersTests.m @@ -17,6 +17,7 @@ @interface TyphoonViewHelpersFactory : TyphoonAssembly - (NSString *)notView; - (UIView *)view; +BOOL equalProperties(NSLayoutConstraint *c1, NSLayoutConstraint *c2); @end @@ -165,8 +166,7 @@ - (void)test_transfer_properties { id secondItem = replaceSecondItem ? dst : srcConstraint.secondItem; if ([dstConstraint.firstItem isEqual:firstItem] && - [dstConstraint.secondItem isEqual:secondItem] && - dstConstraint == srcConstraint) { + [dstConstraint.secondItem isEqual:secondItem]) { didFindEqualPointer = YES; break; }