diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2017-09-03 01:43:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-03 01:43:09 +0300 |
commit | 5f785d062fb1bbf671ccfa87adce44b0b8801cf1 (patch) | |
tree | 9586e2ea764e40866f4f01b16b20e2e0922d072f | |
parent | 61b691cfc6d8573f7d616cbef31ae42dc6efece8 (diff) | |
parent | 14dfb05ec598a271a4243d33d8b4bbeb754bce69 (diff) |
Merge PR #113: MUCertificateCreationView: add constraints for UITextFields in UITableViewCell contentView.
-rw-r--r-- | Source/Classes/MUCertificateCreationView.m | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/Classes/MUCertificateCreationView.m b/Source/Classes/MUCertificateCreationView.m index 3c71446..1844d1a 100644 --- a/Source/Classes/MUCertificateCreationView.m +++ b/Source/Classes/MUCertificateCreationView.m @@ -38,6 +38,17 @@ static void ShowAlertDialog(NSString *title, NSString *msg) { #pragma mark - #pragma mark Initialization ++ (void) configureTableViewConstraintWithCell:(UITableViewCell *)cell andTextField:(UITextField *)textField { + [textField setTranslatesAutoresizingMaskIntoConstraints:NO]; + + NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:textField attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:[cell contentView] attribute:NSLayoutAttributeTop multiplier:1 constant:1]; + NSLayoutConstraint *bottom = [NSLayoutConstraint constraintWithItem:textField attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:[cell contentView] attribute:NSLayoutAttributeBottom multiplier:1 constant:0]; + NSLayoutConstraint *left = [NSLayoutConstraint constraintWithItem:textField attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:[cell contentView] attribute:NSLayoutAttributeLeft multiplier:1 constant:110]; + NSLayoutConstraint *right = [NSLayoutConstraint constraintWithItem:textField attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:[cell contentView] attribute:NSLayoutAttributeRight multiplier:1 constant:0]; + + [[cell contentView] addConstraints:[NSArray arrayWithObjects:top, bottom, left, right, nil]]; +} + - (id) init { if ((self = [super initWithStyle:UITableViewStyleGrouped])) { [self setContentSizeForViewInPopover:CGSizeMake(320, 480)]; @@ -65,6 +76,8 @@ static void ShowAlertDialog(NSString *title, NSString *msg) { [_nameField setClearButtonMode:UITextFieldViewModeWhileEditing]; [[_nameCell contentView] addSubview:_nameField]; + [MUCertificateCreationView configureTableViewConstraintWithCell:_nameCell andTextField:_nameField]; + _emailCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"MUFavouriteServerDescription"]; [_emailCell setSelectionStyle:UITableViewCellSelectionStyleNone]; [[_emailCell textLabel] setText:email]; @@ -83,6 +96,8 @@ static void ShowAlertDialog(NSString *title, NSString *msg) { [_emailField setText:_fullName]; [_emailField setClearButtonMode:UITextFieldViewModeWhileEditing]; [[_emailCell contentView] addSubview:_emailField]; + + [MUCertificateCreationView configureTableViewConstraintWithCell:_emailCell andTextField:_emailField]; } return self; } |