Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of adjustedContentInset in UIWebview?

I have a UIWebView in which i load content from remote URL. Problem i am facing is, last part of the content of webview is not scrollable. When debugging i noticed that adjustedContentInset is set as {0, 0, 49, 0}. Perhaps that is the reason partial webview content(49 pts from end) is not scrollable. Is there any way i can get rid of adjustedContentInset so that the whole content becomes scrollable?

I tried setting the contentInsets of webview's scrollview to {0,0,0,0} but it didn't help.

UITableView and UICollectionView has contentInsetAdjustmentBehavior method to reset adjustedContentInset but i couldn't find such property for UIWebView.

Any help will be appreciated.

like image 981
Vishnu gondlekar Avatar asked Apr 10 '18 08:04

Vishnu gondlekar


1 Answers

Actually, contentInsetAdjustmentBehavior is a UIScrollView property, that's why what you mentioned:

UITableView and UICollectionView has contentInsetAdjustmentBehavior method to reset adjustedContentInset but i couldn't find such property for UIWebView.

is correct.

That means contentInsetAdjustmentBehavior is not a property for the UIWebView (UIView), what would you need to do is to access it via the web view scrollView property:

The scroll view associated with the web view.

Discussion

Your app can access the scroll view if it wants to customize the scrolling behavior of the web view.

which exactly what are you aiming to. Therefore:

webView.scrollView.contentInsetAdjustmentBehavior = ...

should work.

like image 175
Ahmad F Avatar answered Oct 10 '22 21:10

Ahmad F