0

I have a UIViewController with a UITableView as well as a UIView that is above the UITableView but aligned to the bottom of the screen. Problem is when the user is on a phone call, the frame settings don't work, and the UIView is pushed below the screen (so it is slightly covered. I'm trying to just align the UIView to the view bottom and simply not getting it to align. I have the constraints defined as below:

[self.view addSubview:self.signupView];
[self.view addSubview:self.tableView];
[self.view bringSubviewToFront:self.signupView];

NSArray *v = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_signupView(70)]-0-|"
                                                     options:NSLayoutFormatAlignAllBaseline
                                                     metrics:nil
                                                       views:NSDictionaryOfVariableBindings(_signupView)];
NSArray *h = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_signupView]|"
                                                     options:NSLayoutFormatAlignAllBottom
                                                     metrics:nil
                                                       views:NSDictionaryOfVariableBindings(_signupView)];
[self.view addConstraints:h];
[self.view addConstraints:v];

The height of signupView is 70, and it should just be aligned at the bottom of the screen with the width of the entire screen. The above code is putting the view at the top of the view. Is there something i'm missing here? Why is it not aligning with the bottom as I put above? I tried to read the below on this:

http://commandshift.co.uk/blog/2013/01/31/visual-format-language-for-autolayout/

http://makeapppie.com/2014/07/26/the-swift-swift-tutorial-how-to-use-uiviews-with-auto-layout-programmatically/

Use autolayout to set dynamic UIView to match container view

Community
  • 1
  • 1
KVISH
  • 12,923
  • 17
  • 86
  • 162

1 Answers1

0

Figured it out.

Here is the below that worked for me:

NSArray *v = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[_signupView(70)]-0-|"
                                                     options:NSLayoutFormatAlignAllBaseline
                                                     metrics:nil
                                                       views:NSDictionaryOfVariableBindings(_signupView)];
NSArray *h = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_signupView]|"
                                                     options:NSLayoutFormatAlignAllBottom
                                                     metrics:nil
                                                       views:NSDictionaryOfVariableBindings(_signupView)];
[self.view addConstraints:h];
[self.view addConstraints:v];
KVISH
  • 12,923
  • 17
  • 86
  • 162