Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using auto layout with a child UIViewController
#import "SPAutoLayoutChildViewController.h"
@implementation SPAutoLayoutChildViewController
- (void)updateViewConstraints {
if (self.view.superview) {
UIView *thisView = self.view;
thisView.translatesAutoresizingMaskIntoConstraints = NO;
NSDictionary *views = NSDictionaryOfVariableBindings(thisView);
[self.view.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[thisView]|" options:0 metrics:nil views:views]];
[self.view.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[thisView]|" options:0 metrics:nil views:views]];
[super updateViewConstraints];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.