Skip to content

Commit

Permalink
Merge pull request #517 from appsquickly/bugfix/#513-transferring-con…
Browse files Browse the repository at this point in the history
…straints-from-view-to-view-fix

#513 Transferring constraints from view to view fix
  • Loading branch information
alexgarbarev authored Jul 13, 2016
2 parents a83f739 + 13dfcaa commit 48291d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions Source/ios/Storyboard/TyphoonViewHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Tests/iOS/Storyboard/TyphoonViewHelpersTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @interface TyphoonViewHelpersFactory : TyphoonAssembly

- (NSString *)notView;
- (UIView *)view;
BOOL equalProperties(NSLayoutConstraint *c1, NSLayoutConstraint *c2);

@end

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 48291d9

Please sign in to comment.