Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView scrollTo should behave smoothly

I do not know if i asked correctly in Question Title, but here i am going to describe in brief

I have an UIWebView and loading the content based on div and each div has unique id on loadRequest. As though my content was too large so i break down into pieces and loading the remaining content once you tap on 'Read More'

This 'Read More' event fire on autoscroll which i am handling through javascript. so once that event is fired it just append data (for which i have another method) by using window.location.href = div1+div2(its just an example).

Now the main problem is when i scrollDown and wherver i get the 'Read More' message and it auto fire then it adds the data to the current div and show (User feel its an continue reading) but when

I scroll towards to up It behaves weired because it just append the data to the div and scroll to setYScroll(updatedlocation);

updatedlocation is used for when we are adding the content to the div and it should scroll to the same position where the user was.

so lets start with an example, assume currently i am reading the div2 and when i scroll up'Read More' events fired and add div1 to div2 and then web view delegate shouldStartLoadWithRequest called.

so every time its update the content to div2 when you are scrolling up but first it takes me the previous s location of div1 and then take me to div2 location where i was currently reading. so it feel like really weired, suddenly it takes me to somewhere for a while and take me to my current position within friction of second

I tried with this solution, I thought to take the screen shot and create an imageView with that screenshot image of the current UIWebView and put on webview whenever 'Read More' event is happening. once the web view loading is done remove the imageView and display the webview. but this is happening in the same way, the problem is every thing is happening under the webview delegate. i still could not figure out whats happening? The solution of this problem am i on right trackj or is there any better solution for that

like image 798
Praveen-K Avatar asked Aug 09 '11 18:08

Praveen-K


1 Answers

I have a similar situation. What I do is have two UIWebViews on top of each other. When it is time to update one view, I grab the scroll position, load the new data in the hidden UIWebView, when the other UIWebView is done loading its data it sets its scroll position to the current scroll position of the first webview, then hides the first webview and unhides itself. Its pretty seamless and works very well.

like image 120
itgiawa Avatar answered Oct 22 '22 22:10

itgiawa