views:

942

answers:

3

I'm displaying a UISearchBar at the top of a UIWebView for entering information that I use to display content in the UIWebView. Is there a way to attach the UISearchBar (or perhaps a UITextField?) to the UIWebView "header" so that when the user scrolls down on the webview the UISearchBar also scrolls out of view and the full window is able to display text?

If this is not possible, how else could I accomplish this while still using the UIWebView for it's inherent text formatting capabilities?

+1  A: 

You may try containing the UIWebView and UISearchBar within a UIScrollView. That is, create a controller that has the main view as a UIScrollView and then add in the UISearchBar and UIWebView as subviews. If you want custom behavior when you're scrolling you may have to override the event callbacks for scrolling. I haven't tried this but in theory you could have it so that when you get a scroll down and the UISearchBar is in view, you hide it up to a certain # of pixels until the UISearchBar is hidden. Afterwards you forward the scroll request to the UIWebView so it can deal with things. Basically have a middleman that delegates the scroll events as necessary.

Ish
A: 

Did you end up able to accomplish this, Liu?

umop
A: 

Go through this question / answer - Hope, It would be helpful to you. http://stackoverflow.com/questions/1004094/how-can-i-search-in-an-uiwebview

sugar