// // ProgrammaticScrollViewController.m // myverizon // // Created by Scott Pfeil on 1/26/16. // Copyright © 2016 Verizon Wireless. All rights reserved. // #import "ProgrammaticScrollViewController.h" #import #import "NSLayoutConstraint+MFConvenience.h" #import "MVMCoreUICommonViewsUtility.h" @interface ProgrammaticScrollViewController () @end @implementation ProgrammaticScrollViewController - (void)loadView { UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; view.backgroundColor = [UIColor whiteColor]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; scrollView.backgroundColor = [UIColor clearColor]; [scrollView setTranslatesAutoresizingMaskIntoConstraints:NO]; [view addSubview:scrollView]; // Sets the constraints for the scroll view NSDictionary *constraints = [NSLayoutConstraint constraintPinSubviewToSuperview:scrollView]; self.topConstraint = [constraints objectForKey:ConstraintTop ofType:[NSLayoutConstraint class]]; self.bottomConstraint = [constraints objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]]; UIView *contentView = [MVMCoreUICommonViewsUtility commonView]; [scrollView addSubview:contentView]; // Sets the constraints for the content view [NSLayoutConstraint constraintPinSubviewToSuperview:contentView]; // Super will set later. NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:320.0]; self.contentWidthConstraint = widthConstraint; widthConstraint.active = YES; self.contentView = contentView; self.scrollView = scrollView; self.view = view; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end