Authored by 0oneo

make UIScrollView demo more self-explanation

@@ -39,8 +39,10 @@ @@ -39,8 +39,10 @@
39 UIView* contentView = UIView.new; 39 UIView* contentView = UIView.new;
40 [self.scrollView addSubview:contentView]; 40 [self.scrollView addSubview:contentView];
41 [contentView makeConstraints:^(MASConstraintMaker *make) { 41 [contentView makeConstraints:^(MASConstraintMaker *make) {
42 - make.edges.equalTo(self.scrollView);  
43 - make.width.equalTo(self.scrollView.width); 42 + make.edges.equalTo(self.scrollView); // let the UIScrollView knonw where the edge is the contentView
  43 + // the size of UIScrollView's contentView must be able to caculated by the constraints. here set the width;
  44 + // the height will be set bellow.
  45 + make.width.equalTo(self.width);
44 }]; 46 }];
45 47
46 UIView *lastView; 48 UIView *lastView;
@@ -66,12 +68,8 @@ @@ -66,12 +68,8 @@
66 lastView = view; 68 lastView = view;
67 } 69 }
68 70
69 - // dummy view, which determines the size of the contentView size and therefore the scrollView contentSize  
70 - UIView *sizingView = UIView.new;  
71 - [scrollView addSubview:sizingView];  
72 - [sizingView makeConstraints:^(MASConstraintMaker *make) {  
73 - make.top.equalTo(lastView.bottom);  
74 - make.bottom.equalTo(contentView.bottom); 71 + [contentView makeConstraints:^(MASConstraintMaker *make) {
  72 + make.bottom.equalTo(lastView.bottom);
75 }]; 73 }];
76 74
77 return self; 75 return self;