title: UIScrollView Autolayout prevent from scrolling vertically
body: <p>I'm wondering how to crop image inside UIscrollView with autolayout
  I'm trying to make UIscrollView scroll only horizontally.  if image is higher than view height it should be cropped. I've tried a lot properties but can't make all images inside uiscrollview same height as view to avoid scrolling vertically.
  Do i miss something?</p>
  
  <pre><code>#import "WelcomeController.h"
  
  @interface WelcomeController ()
  @property (strong, nonatomic) UIScrollView *scrollView;
  @property (nonatomic,strong) NSArray *contentList;
  @end
  
  @implementation WelcomeController
  @synthesize contentList =_contentList;
  
  - (void)updateUI
  {
  
      UIScrollView* sv = self.scrollView;
  
      id previousLab = nil;
  
      for (UIView *lab in _contentList) {
          lab.translatesAutoresizingMaskIntoConstraints = NO;
          lab.backgroundColor = [UIColor blackColor];
          lab.contentMode = UIViewContentModeScaleAspectFit;
          [sv addSubview:lab];
          [sv addConstraints:
           [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[lab]|"
                                                   options:0 metrics:nil
                                                     views:@{@"lab":lab}]];
          if (!previousLab) { // first one, pin to top
              [sv addConstraints:
               [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[lab]"
                                                       options:0 metrics:nil
                                                         views:@{@"lab":lab}]];
          } else { // all others, pin to previous
              [sv addConstraints:
               [NSLayoutConstraint
                constraintsWithVisualFormat:@"H:[prev][lab]"
                options:0 metrics:nil
                views:@{@"lab":lab, @"prev":previousLab}]];
          }
          previousLab = lab;
      }
      // last one, pin to bottom and right, this dictates content size height
      [sv addConstraints:
       [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[lab]|"
                                               options:0 metrics:nil
                                                 views:@{@"lab":previousLab}]];
      [sv addConstraints:
       [NSLayoutConstraint constraintsWithVisualFormat:@"H:[lab]|"
                                               options:0 metrics:nil
                                                 views:@{@"lab":previousLab}]];
  
  }
  
  -(void)setContentList:(NSArray *)contentList
  {
      _contentList = contentList;
      [self updateUI];
  }
  
  - (void)setupScrollView
  {
      UIScrollView* sv = [UIScrollView new];
      sv.backgroundColor = [UIColor redColor];
      sv.translatesAutoresizingMaskIntoConstraints = NO;
      sv.pagingEnabled = YES;
      sv.showsHorizontalScrollIndicator =NO;
      sv.showsVerticalScrollIndicator = NO;
      sv.bounces =NO;
      [self.view addSubview:sv];
      [self.view addConstraints:
       [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[sv]|"
                                               options:0 metrics:nil
                                                 views:@{@"sv":sv}]];
      [self.view addConstraints:
       [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[sv]|"
                                               options:0 metrics:nil
                                                 views:@{@"sv":sv}]];
      self.scrollView = sv;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      [self setupScrollView];
  
      //for testing
      UIImageView *image1=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"welcome1.jpg"]];
      UIImageView *image2=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"welcome2.jpg"]];
      UIImageView *image3=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"welcome3.jpg"]];
      self.contentList = [NSArray arrayWithObjects:image1,image2,image3,nil];
  }
  
  
  
  @end
  </code></pre>