views:

391

answers:

1

I'd like to display a toolbar above a UIWebView but hide the toolbar until the person "pulls it down".

The same functionality can be seen in Safari on the iPhone. When the page loads, the toolbar containing the address is hidden. You must pull it down. In Safari it's possible to scroll up and eventually see the toolbar or scroll down through the page contents.

I've tried placing a UIToolbar and UIWebView inside a UIScrollView but it didn't work. I've tried setting the UIScrollView to the size of the toolbar and webview combined, but that didn't work.

- (void)viewDidLoad{
    CGSize size = CGSizeMake(webView.frame.size.width,
                              toolBar.frame.size.height + webView.frame.size.height);
    [scrollView setContentSize:size];
}

How should I go about doing this?

A: 

The UIWebView is itself a UIScrollView so it's not going to work. I'm not sure how Apple does it, but one way to do it, if you have control over the content of the web view, is to write some HTML and CSS that replicates that address bar.

lucius
Unfortunately, you're right. Not only does the UIWebView contain a scroller, but it doesn't give direct access to it.I eventually gave up and added a UIToolbar and UIWebView together to a UIView. The UIToolbar is always visible, but at least it's stable.
Nick VanderPyle
UIWebView is NOT a UIScrollView
Sam
UIWebView is not a subclass of UIScrollView, however it does conform to the UIScrollViewDelegate protocol, and therefore can be treated like a UIScrollView in how it sends messages to its delegate.
lucius