Teknos
Teknos

Reputation: 411

UIScrollview works in iOS8, not in iOS7

I have a scrollview that is working in iOS8, but not in iOS7. My xib file has the scrollview outside the main view. I add the scrollview to the view with:

helpScrollView.contentSize = helpScrollView.frame.size;
helpScrollView.frame = self.view.frame;
[self.view addSubview:helpScrollView];

I have confirmed by printing the values to the console that the content size after this is 320x670 and the frame size of the window to be 320x568. However, in iOS7, the scrollview won't scroll even though the content is cut off. It will scroll as expected in iOS8. The scrollview contains a multiline label that fills the scrollview. I am getting a warning for "Automatic Preferred Max Layout is not available" so that could be related. Any help would be great!

Joseph

Upvotes: 0

Views: 684

Answers (1)

FedeH
FedeH

Reputation: 1373

It work for me, "For some reason, viewDidLoad is too early in the life cycle to obtain the scroll view's adjusted frame on iOS 8, but again it works on iOS 7. viewWillAppear is also too early, as well as viewWillLayoutSubviews.

To solve the problem, I just moved the code where I need to use the scroll view's frame size to viewDidLayoutSubviews which does finally obtain the correct size it will be when it appears." UIScrollView frame is a different size on iOS 8 vs iOS 7

Upvotes: 2

Related Questions