I trying to implement page view controller with three pages. I already did it, it works very well on iPhones with 3.5- and 4-inch displays, but something wrong happens with 4.7- and 5.5-inch displays.
I found that hiding of standard Page Control of UIPageViewController is reason of this bug: when page control gets hidden the view of UIPageVC changes his height (+ height of Page Control View).
My page content view controllers has constraints for background image view to fit to all sizes.
This is first page:
This is second page:
This is third page, ok, we've reached last page:
But look what happens when we return to the second page (View of page content controller fully moved at few pixels to the left):
Swipe to the first page - the same result:
BUT! Look what we have when after the first page we go to the second page! Now view of page content controller at the right position by x:
Go to the last page:
Let's come back to the second page! Holy ****! View gets moved by something again:
Go to the first page, all in the 'right' (BAD) positions:
Go back to the second page from first page. All in the good and right positions:
So, my question is what is going on with this UIPageViewController? I thought that my constraints gets broken but I have nothing in my logs about it, in storyboard there are no error related to constraints.
When I use two methods "presentationCountForPageViewController:, presentationIndexForPageViewController:" all is good but above the button appears a white line of height equal to Page Control view's height (so, I need to hide it by erasing two methods listed above).
Thanks in advance for you future suggestions!
I fixed it! But not by the right way because it is iOS-side bug.
So, when you trying to hide Page Control View of your UIPageViewController the private 'pageSpacing' property gets broken on iPhone 6 and iPhone 6 Plus by unexpected reason. It is hard to see and understand it from views. In my case for iPhone 6 InterPageSpacing property has been decreased by 4 and for iPhone 6 Plus - by 6 values. So, if you'll try to to set pageSpacing property for iPhone 4 or 5 you'll see a white line between pages but on 6 and 6 Plus this line disappears and view of second controller moves to few pixels left.
For now I just set different values for UIPageViewControllerOptionInterPageSpacingKey while initialize my UIPageViewController:
- (id)initWithTransitionStyle:(UIPageViewControllerTransitionStyle)style navigationOrientation:(UIPageViewControllerNavigationOrientation)navigationOrientation options:(NSDictionary *)options
{
NSMutableDictionary *dictionary = [NSMutableDictionary new];
NSNumber *pageSpacing =
IS_IPHONE_4_OR_LESS
? @(0)
: IS_IPHONE_5
? @(0)
: IS_IPHONE_6
? @(4)
: @(6);
[dictionary setValue:pageSpacing forKey:UIPageViewControllerOptionInterPageSpacingKey];
self = [super initWithTransitionStyle:style navigationOrientation:navigationOrientation options:dictionary];
return self;
}
Yes, fix is dirty but I didn't find another way to fix it, especially as it is bug of Apple.