a reference to the UIWebView class prevents the implementation of UIWebView in UIScrollView:
Important: you must not embed UIWebView or UITableView objects in UIScrollView Objects. If you do this, unexpected behavior may occur because touch events for two objects can be mixed and mistakenly processed.
However, I suppose you still want to implement your function ;-)
Idea 1 . Do not embed a UIWebView in a UIScrollView, instead run javascript using the UIWebView method stringByEvaluatingJavaScriptFromString: by changing the DOM to add the toolbar below. If necessary, you can call the objective-c code from any buttons pressed on the toolbar by registering some custom URL schemes.
Idea 2 . Do not embed a UIWebView in a UIScrollView, but in a regular UIView. Based on the Vignesh clause, listen for the internal scrollView web scrollViewDidScroll: through the delegate, checking the heights of contentOffset and contentSize each time the callback is called. Once they are equal, it means that you have reached the point. Once this happens, you can animate the toolbar frame to the โenterโ containing the UIView and โpushโ the webView frame.
Idea 3 . Ignore Apple's recommendation and insert UIWebView into UIScrollView. Based on the Vignesh clause, listen for the internal scrollView web scrollViewDidScroll: through the delegate, checking the heights of contentOffset and contentSize each time the callback is called. Once they are equal, it means that you have reached the point. Once this happens, set the userInteractionEnabled property for the webView to NO and set it to YES on the scrollView that contains the webView and toolbar. We hope that the scrolling will continue smoothly enough. Of course, you should listen to the containing scroll view in the same way to determine when userInteractionEnabled needs to be returned.
A variant of this idea would be to simply set userInteractionEnabled to NO for the webView, but set the height of the webView frame according to its contentSize, and also increase the contentSize of the containing scrollView accordingly.
Both options have the disadvantage that in some cases you wonโt be able to do such things as clicking on the links :-( But maybe this is good enough for your business. At least in the first version it is not so bad.
Danra
source share