0

i have an app that have a scroll view embeded in main view like follow (that is programmatically set constraints with Masonry, hope its easy to understand that scroll view just fit in main view):

[self.mainScroll mas_makeConstraints:^(MASConstraintMaker * make) {
        @strongify(self)
        make.top.mas_equalTo(self.view);
        make.left.mas_equalTo(self.view);
        make.right.mas_equalTo(self.view);
        make.bottom.mas_equalTo(self.view);
    }];

- (void)viewWillLayoutSubviews {

    self.mainScroll.contentSize = (CGSize){self.view.bounds.size.width - 4, NEWS_HEIGHT + 2 + (ITEM_HEIGHT + 1) * self.viewModel.arrValues.count/2 + (ITEM_HEIGHT + 1) * (self.viewModel.arrValues.count % 2) + PLUS_BAR_HEIGHT };

}

In iPhone it work fine, it scrolls when it need, but in iPad it doesn't. I checked, and method calls many times, but, even if i explicitly set something like:

- (void)viewWillLayoutSubviews {

    self.mainScroll.contentSize = (CGSize){self.view.bounds.size.width - 4, 2000 };

}

Any ideas why its happen?)

Evgeniy Kleban
  • 6,794
  • 13
  • 54
  • 107
  • With a 2000 point contentSize height it should scroll no matter what. Perhaps try the View Debugger, you may have placed some other (transparent) view on top of the scrollView that is positioned in a right way on iPhone, but on iPad it may overlap the scrollview – Zoltán Matók Mar 05 '16 at 13:32
  • Why wont you use native auto layouts instead, see this link if it is helpful to you. http://stackoverflow.com/questions/35624873/ios-scrollview-needs-constraint-for-y-position-or-height/35625897#35625897 – Bharat Modi Mar 05 '16 at 13:33
  • @ZoltánMatók maybe scroll view height is increased, but it bound with self.view, and self.view height isnt changed? – Evgeniy Kleban Mar 05 '16 at 15:25
  • If it's bound to self.view.height, it shouldn't grow. Did you try the View Debugger? – Zoltán Matók Mar 07 '16 at 10:08
  • @BharatModi Because doing pure Auto Layout in code is awful :) I myself use Neon (https://github.com/mamaral/Neon) – Zoltán Matók Mar 07 '16 at 10:11
  • @ZoltánMatók however it grows when launched for iPhone not iPad )) – Evgeniy Kleban Mar 07 '16 at 10:20

0 Answers0