0

I have an app that contains a UIScrollView with 3 pages. It will swap pages when a over scrolls 50% over to the next element, and each page is an own UIViewController(And each of them contains UILabels and UITextFields). Each page has a width set equals the width of the current device.

This works perfectly on iOS 8, but the scrollview is 33% too small on iOS 7, and each view.frame.orgin.x is 33% too small, so the views overlaps. The width of each of the pages is, however, correct.

My question is, why is this offset by 33%? Why does this work perfectly on iOS 8, but not on iOS 7?

Original code for scrollview:

scrollview.contentSize = CGSizeMake((screenRect.size.width * 3), scrollview.frame.size.height);

Scrollview code that actually work:

CGRect screenRect = [[UIScreen mainScreen] bounds];
if([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0)
{

    scrollview.contentSize = CGSizeMake((screenRect.size.width * 3) * 1.334, scrollview.frame.size.height);
}
else
{
    scrollview.contentSize = CGSizeMake((screenRect.size.width * 3), scrollview.frame.size.height);
}

Relevant code for each of the pages:

CGRect frame = [[UIScreen mainScreen] bounds];
if([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0)
{
    frame.origin.x = (frame.size.width * page) * 1.334;
}
else
{
    frame.origin.x = (frame.size.width * page);
}
frame.orgin.y = 0;
vebbi
  • 119
  • 11

2 Answers2

0

You seems to specifically increasing content size by 30% on OS less then 8.0. And that causes overlapping. What exactly is not clear?

sha
  • 17,824
  • 5
  • 63
  • 98
  • I increase the size because it's 33% too small. This code works on both iOS 7 and iOS 8. But I don't see why. I think my question was a bit unclear: Why does iOS 7 need the 33% extra? – vebbi Nov 12 '14 at 16:35
  • Why don't you debug it and check values for page width, frames etc? – sha Nov 12 '14 at 16:37
  • I did. They are both equal. Also I seem to be the only one with this issue. – vebbi Nov 12 '14 at 16:40
  • This doesn't make any sense. What device are you running it on iOS7 and iOS8? What value are you getting from screenRect.size.width? – sha Nov 12 '14 at 16:43
  • Forget what I said. They are not equal. My app is in landscape mode only, and on iOS 7 [UIScreen mainScreen].bounds's width and height is not orientation dependant, but that has changed from iOS 8. http://stackoverflow.com/questions/24150359/is-uiscreen-mainscreen-bounds-size-becoming-orientation-dependent-in-ios8/25791923#25791923 – vebbi Nov 13 '14 at 12:15
0

My issue was that iOS 8 is different from iOS 7 when it comes to [[UIScreen mainScreen] bounds].

I found the answer to my issue here:

Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?

Community
  • 1
  • 1
vebbi
  • 119
  • 11