views:

2425

answers:

7

How can i add scroll bars to uiwebview. should i put it in uiscrollview. In that case, i'm getting nothing :( Any help will be appreciated.

Thanks.

+1  A: 

The scrollbars are added automatically when you put content in your UIWebView. Be sure to uncheck "Scales Page to Fit" in Interface builder, so the page is not rescaled when displayed.

Stephan Burlot
+1  A: 

UIWebView will automatically display scrollbars when it has content that exceeds the height of the UIView.

lostInTransit
A: 

Not happening guys. :(

I'm adding the UIWebView in a table cell. But that should not prevent him to add/show UIWebView's scrollbar. And, i'm showing text in UIWebView, not a HTML page. Any ideas?

Mustafa
It would be helpful if you could edit your original question to include the information in these two answers. Then if you deleted these answers it would make this whole question easier to read (I was confused why some of the answers where talking about table cells when that wasn't mentioned in the original post). Anyhow, just a suggestion :-)
Dan J
+2  A: 

The problem with adding UIWebView into a table cell is both these objects are scrollable (tableview and webview) which will create complications if not used appropriately. Does you tableview have any cells other than uiwebview? and do you need the tableview to be scrollable? In case the tableview need not be scrollable, make scrolling enabled in the webview and disabled for the tableview. That should work.

But if you want to just display text, why not use a UITextView (though you'll face the same problem for UITextView too)?

lostInTransit
A: 

My table view does have multiple cells and a header frame as well, and i do need it to be scrollable because it has many rows.

Actually the text displays perfectly fine with UITextView and shows scrollers as well, problem is that my content is rich text, so i don't have any other option but to show the content in UIWebView. Any ideas, hacks?

Mustafa
+3  A: 

Unless Apple does something about it, this can't work. Both UITableView and UIWebView support scrollers, and they contradict with each other. UITableView scrollers take precednce so whenever a scroll operation is performed, the action is sent to UITableView instead of UIWebView.

For some reason, when using UITextView with UITableView, scrollers work for both.

Mustafa
+1  A: 

You can put a UIWebView into a UIScrollView and have both scrollable by setting the canCancelTouchEvents property of the UISCrollView to NO. If you just flick, the UIScrollView will scroll. If you hold your finger down for a short period of time and then start to flick, the UIWebView will scroll.

MrMage