I have a really long UIWebView, and I need to add a way for the user to tap the UINavigationBar to scroll to top (something like the Facebook app, where it's little glow when you tap).
How can I do this?
I have a really long UIWebView, and I need to add a way for the user to tap the UINavigationBar to scroll to top (something like the Facebook app, where it's little glow when you tap).
How can I do this?
First, you could create a custom view for the titleView of your UINavigationItem
that handles the touch events.
Second, I'm a little more hazy on, but it would appear that getting a UIWebView to scroll to the top of its contents is a bit harder than with a UITableView (UIWebView does not inherit from UIScrollView). There has been some discussion about it in this question http://stackoverflow.com/questions/1361614/iphone-os-tap-status-bar-to-scroll-to-top-doesnt-work-after-remove-add-back. However, the proposed solution:
((UIScrollView *)[[webView valueForKey:@"_internal"] valueForKey:@"scroller"]).scrollsToTop = NO;
may violate the new static checking that Apple is doing on apps.
You could use javascript to scroll the web view to the top. You could execute the javascript from the Objective-C side using
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script