Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy Shouldn't A UIWebView Be Placed in a UIScrollView?
    text
    copied!<h2>The Question</h2> <p><strong>Does anyone know of technical reasons for avoiding web views inside scroll views on iOS</strong> (assuming you're willing to disable scrolling inside the web views themselves)?</p> <p>If you look <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html" rel="noreferrer">at the Apple docs for UIWebView</a>, they state:</p> <blockquote> <p><strong>Important:</strong> 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.</p> </blockquote> <h2>My Educated Guess</h2> <p>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.</p> <p>But, there's a very valid reason to want to put a <code>UIWebView</code> inside a scroll view. Web views aren't <em>just</em> scroll views. <code>UIWebView</code> can easily display a wide range of <strong>web</strong> content.</p> <p>If there is no need to allow scrolling <strong>within</strong> the <code>UIWebView</code> itself, and you turn off scrolling with either:</p> <pre class="lang-objc prettyprint-override"><code>webView.userInteractionEnabled = NO; </code></pre> <p>or</p> <pre class="lang-objc prettyprint-override"><code>webView.scrollView.scrollEnabled = NO; </code></pre> <p>then is there really any problem with this design?</p> <p>I'm wondering if this is partly an artifact of the original <code>UIWebView</code> interface, where it did not give you <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIWebView/scrollView" rel="noreferrer">direct (and documented) access</a> to its embedded <code>UIScrollView</code> (to be able to disable its scrolling easily). Maybe this statement in the Apple docs is a legacy of that?</p> <h2>Project Context</h2> <p>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 <code>UIWebViews</code> inside a <code>UIScrollView</code> were chosen for that. So far, it appears that it <em>may</em> be working properly.</p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload