Alessandro
Alessandro

Reputation: 4100

UIWebView prevents UITableView to scroll

I have a cell in my UITableView with a UIWebView. The problem is that if you swipe on the UIWebView you swipe throughout the internet page, and not the table view. Since the web view has a hight of 500, it is possible that the user is stuck in the web view. Does anyone have any ideas in how to solve the problem?

Upvotes: 4

Views: 1465

Answers (2)

Gavin
Gavin

Reputation: 8200

Beginning with iOS 5, there is a scrollView property on UIWebView, so you can just do the following on your web view:

webView.scrollView.scrollEnabled = NO; 
webView.scrollView.bounces = NO;

Then you should be able to scroll just fine. No need to disable interaction on the web view, unless you don't want the user to be able to interact with it at all.

Upvotes: 4

Nick
Nick

Reputation: 2369

If the user does not need to interact with the webview, you can set webview.userInteractionEnabled to NO.

If they need to interact with it, but don't need to scroll, you can set webview.scrollView.scrollEnabled to NO

Either of those solutions should allow scrolling to pass through to the tableView.

If they need to scroll the webview, I'd suggest rethinking your UI. AFAIK, Apple advises against having nested scrollviews.

Upvotes: 3

Related Questions