3

I have a UISplitViewController whose detail is a UIPageViewController. Each page view controller just shows a WKWebView.

The problem is that on an iPhone 6(s) Plus in landscape mode, I can't scroll from page to page using the page view controller if the html being displayed includes the very common <meta name='viewport' content='width=device-width'>. I can still scroll, zoom and pan the WKWebView, but the UIPageViewController simply will not allow me to turn the page.

The problem doesn't occur in other horizontally-regular environments (iPads in either orientation), nor in any compact ones (iPhone 6 Plus in portrait mode, or other iPhones). It doesn't matter whether the UIPageViewController uses the "scroll" transition style or the page curl.

Am I doing something wrong, or is this an Apple bug? If the latter, are there any workarounds?

phu
  • 1,199
  • 2
  • 10
  • 20

2 Answers2

0

OK, I had the same problem. I had a custom SplitViewController, but the same behavior (can't swipe to the next page on iPhone 6 Plus in landscape). The issue was that the splitview must have made the webview just a pixel or so too small so that the webview's gesture recognizer captured the touch event that was meant for the UIPageView. Why? Because the webview's content had to "scroll" to the right for a pixel or so. Slightly adjusting my split-ratio fixed it.

Try slightly adjusting the preferredPrimaryColumnWidthFraction, I'm sure this will fix your problem.

Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165
  • I tried adjusting `preferredPrimaryColumnWidthFraction` with no luck, and `primaryColumnWidth` is read-only. What value did you use, and where are you setting it? – phu Dec 08 '15 at 20:23
  • @phu I have a custom split view controller (not a subclass of UISplitViewController). Which WidthFraction values did you try? – Johannes Fahrenkrug Dec 08 '15 at 21:36
  • Several different values, mostly obvious ones like 0.3, 0.4, 0.5. If you're not using a `UISplitViewController` subclass, what made you so sure that setting `preferredPrimaryColumnWidthFraction` would solve the problem? – phu Dec 08 '15 at 21:43
  • @phu Excellent question. Well, in my case it had to do with the size of the view controller that contained the webview (as explained in my answer). So adjusting a width-constraint did the trick for me. On UISplitViewController, it seems as if you achieve the same thing by changing preferredPrimaryColumnWidthFraction. Are you able to swipe from right to left? – Johannes Fahrenkrug Dec 08 '15 at 21:52
0

The UISplitViewController reports an incorrect width to the WKWebView control, probably related to the splitter divider line. This results in horizontal scrolling of the WKWebView, which conflicts with the UIPageViewController. Use this code to fix this:

webView.scrollView.contentInset = UIEdgeInsetsMake(0, -1, 0, 0) 
Ely
  • 8,259
  • 1
  • 54
  • 67