Forgive me if the answer to my question is covered in the very next chapter, but when I click on an item in the table view and the web page loads in the UIWebView, the web page scrolls all the way to the bottom. Yuck!
I know that the web view is embedded in a UIScrollView, and I guessed that UIWebView has a delegate; so I set up this method in WebViewController, after making it the delegate of its view:
- (void)webViewDidFinishLoad:(UIWebView *)webView
[[webView scrollView] setContentOffset:CGPointZero animated:NO];
This more or less works the way I want it to—the page loads at the top. However, there is this nasty flash when the page loads. I’m guessing that the page loads and scrolls all the way to the bottom (as it does without my method) and then immediately jumps to the top, causing the apparent flash to the user. I tried putting this functionality in webViewDidStartLoad:, but that has no effect. It seems like the page needs to finish loading before you can reposition it in the scroll view.
Is there a prettier way of handling this? My guess is that there is a way of loading the page “offscreen” and then putting it in the scroll view with the desired offset—something like that anyway. Maybe there’s a better way of doing it. Any ideas? Thanks!