The Question
Does anyone know of technical reasons for avoiding web views inside scroll views on iOS (assuming you're willing to disable scrolling inside the web views themselves)?
If you look at the Apple docs for UIWebView, they state:
Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.
My Educated Guess
It looks like maybe they're warning you against putting a scroll view inside another scroll view, because touches can be confused between the inner, and outer scroll views.
But, there's a very valid reason to want to put a UIWebView
inside a scroll view. Web views aren't just scroll views. UIWebView
can easily display a wide range of web content.
If there is no need to allow scrolling within the UIWebView
itself, and you turn off scrolling with either:
webView.userInteractionEnabled = NO;
or
webView.scrollView.scrollEnabled = NO;
then is there really any problem with this design?
I'm wondering if this is partly an artifact of the original UIWebView
interface, where it did not give you direct (and documented) access to its embedded UIScrollView
(to be able to disable its scrolling easily). Maybe this statement in the Apple docs is a legacy of that?
Project Context
I ask because I'm maintaining an app (written by someone else) that uses a handful of web views inside a scroll view that allows scrolling between them horizontally. The web content must be considered fixed (not changeable), and it only shows one page of content per HTML page. The user needs to be able to scroll between pages, so multiple UIWebViews
inside a UIScrollView
were chosen for that. So far, it appears that it may be working properly.
However, the pages show full screen images, and scrolling performance is an issue. But, I'm trying to determine if the fundamental nesting of web views inside scroll views (which Apple warns against) is really part of the problem.