Niklas Berglund
Niklas Berglund

Reputation: 3583

How bad is it to embed UIWebView in UIScrollView?

So Apple is saying that UIWebView and UITableView objects shouldn't be embedded in UIScrollView objects. https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/index.html

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.

Does that mean we should never have web or table views inside scroll views? I'm implementing an app that have several web views and table views that scroll with the rest of the content of the view, so scrolling in the web and table views is disabled.

To never place web or table views inside scroll views would mean big design changes. Is Apple saying that we should never keep web and table views inside scroll views, meaning we can never have them scroll with the rest of the view's content?

Or will it work OK as long as scrolling is disabled for the web and table view embedded in the scroll view? If not - are there any better alternatives other than redesigning the app?

Upvotes: 1

Views: 569

Answers (2)

Jasper
Jasper

Reputation: 7107

I have used a UITableView inside a UIScrollView in a production app.

Example:

List of POI's in a UITableView and MKMapView next to each other inside a UIScrollView with paging enabled.

The problem was indeed that the scrolling of the UIScrollView did not actually work. Especially on the MKMapView, as this scrolls in all directions. The workaround was to create a custom UIView with two UIButton's which act as a custom UISegmentedControl. These will actually scroll the UIScrollView to the selected page.

Some of the things Apple puts in their documentation is probably there to be able to comment on bug reports, or to say: See, we told you so.

Upvotes: 1

Max
Max

Reputation: 774

UIWebView ans UITableView inherit from a UIScrollView, so they will scroll if the content exceed the screen size. If you use it in a UIScrollView its a UIScrollView in an other. That's why it can cause problems.

And if you want to use scrolling view in another, you should change the design of your app.

Upvotes: 0

Related Questions