0

I was wrestling with UIScrollview and it knocked me out. I tried to take reference from following two post on stackOverFlow

scrollview xcode4.5 autolayout, Xcode 4.5 UIScrollView, Embed ImageView in ScrollView with Auto Layout on iOS 6,

I tried viewDidLayoutSubviews, as told in UIScrollView setContentSize breaks view with Auto Layout that is causing my app to crash.

And I tried ViewDidLoad, viewDidAppear and viewWillAppear but nothing worked. I tried google and found couple more related post https://coderwall.com/p/zfe8da, http://www.devx.com/wireless/Article/45113

I tried to rethink and didnt find anything fancy that I was not doing. It seems simple, straight approach.

I am out of clues or any guess please help me.

I am using following code, just to mentioned I have 3 images that I have put in the ScrollView. I have stack them on top of each other so there height is more than iPhone screen height. I was expecting it I set them just scroll simple, but guess I was wrong. In Implementation file

_howtoScrollView.frame = CGRectMake(0, 0, 320, 460);
_howtoScrollView.scrollEnabled = YES;
[self.howtoScrollView setContentSize:CGSizeMake(self.howtoScrollView.frame.size.width, 700)];
[self.view addSubview:_howtoScrollView];

In interface file .h

@property (weak, nonatomic) IBOutlet UIScrollView *howtoScrollView;

Anyone who got success with ScrollView while having StoryBoard Autolayout.

Community
  • 1
  • 1
Alix
  • 2,747
  • 3
  • 24
  • 43

4 Answers4

0

Try removing _howtoScrollView.frame = CGRectMake(0, 0, 320, 460);, see if it works.

If you really need to change the frame of a view, in Autolayout, you should not set the frame directly in your code, you should modify the Constraint instead.

YuAo
  • 1,427
  • 1
  • 10
  • 17
  • Nope it does work either by commenting _howtoScrollView.frame = CGRectMake(0, 0, 320, 460); line ... – Alix Mar 06 '13 at 05:18
0

Try to do it without the "addSubview" function. I think that with AutoLayout override your other settings...

Idan
  • 9,751
  • 8
  • 46
  • 75
0

Using interface builder,

expand your scroll view's Constraints section. Then select 'Horizontal Space Constraint'. Under that section you must be probably having a negative value for the 'constant' value. Change it to 0. It will do the trick.

Rukshan
  • 7,586
  • 6
  • 37
  • 58
0

I had this problem too. Apple hid the explanation in the release notes. http://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0. Look under the UIKit section.

Marty
  • 5,576
  • 8
  • 49
  • 86