UIWebView with UISearchBar for searching - iphone

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?

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.

Related

UITextView interferes scrolling of UIScrollView

The problem I am encountering now is that there is a UITextView component in UIScrollView and that UITextView component will interfere the scrolling of UIScrollView, i.e. when a user's finger is on that UITextView to scroll the whole UIScrollView, the screen won't scroll. The content in the UITextView is dynamic, i.e. the size of UITextView component is dynamic. The worst case is the whole screen is occupied by the UITextView and users won't be able to scroll the screen at all.
The UITextView is disabled for editing. I choose UITextView instead of UILabel because I want to detect phone number & link in the supplied text and utilize the built-in function to invoke dialer and browser when users click the phone number or link.
Any suggestion about how I can solve this problem or any clue about why this happens are all appreciated! Thanks.
UITextView inherits from UIScroll view so it has a property scrollEnabled. Just put it to false!
If you are using a storyboard or nib file, select your UITextView and uncheck Scrolling Enabled in Interface Builder.
Otherwise, do this:
textView.scrollEnabled = NO;
Apart from the property scrollEnabled, you also have the property userInterationEnabled that disable(if you set it to FALSE/NO) any touch events on the view (scrolling included, of course). Hope it helps, specially for other situations cos in your case it makes the same effect as disabling the scroll.

Stop UITableView from animating for keyboard

I have an UITableView with a single cell that contains an UITextView. When calling -becomeFirstResponder on the UITextView my UITableView gets messed up by the automatic animation. This only occurs when the UITextView has to scroll down for the end of the text.
I already tried disabling scrolling on the UITableView.
Depending on the needs of your interface, you could probably do what you're asking by making the parent view controller an instance of UIViewController instead of UITableViewController (which is what provides that "slide to get out of the way of the keyboard" behavior).
Indeed, if your UI consists solely of a text view, you probably don't need a table view at all.

UIWebView Inside UIScrollView Html Links Not Working

I have added a UIWebView along with some labels inside UIScrollView (using StoryBoards) by adding it as a subview and then setting the ScrollView height to show all the html content of WebView that is loaded in it using loadHtmlString.
The links in the html content are not working. A little searching revealed that Apple does not recommend putting UIWebView inside UIScrollView to avoid unexpected behaviour. But as i also have to add labels and other stuff other than the UIWebView, so i have to embed them inside UIScrollView.
Is there any way I can make the links work in the html content without violating and Apple's recommendation?
There is no reason to put a UIWebView inside a ScrollView. UIWebView will scroll and zoom and pan the content properly as is. It is sort of redundant unless you have some other layout reasons for example combining it with some other views.
The correct way to add your labels is to add them to a UIViewController or NavigationController and have them positioned around the UIWebView and to also add the UIWebView to that as well.

Can we add UIbuttons, uilabels on to webview and make them scrollable along with the web view in iPhone?

I was working on webview. I am facing an issue where I want to display html as well as UIbuttons.
I made webview added Ui butons but when I scroll webview the webview scrolls but the uibuttons remain at the same location.
I've not actually tried this, but in theory this should be possible on iOS 5. If you just add the button to the UIWebView it won't work - as you'll find, when you scroll the views you add remain in place. In iOS 5 Apple added the scrollView property to UIWebView, so if you add your views to that instead (the scroll view) you may find it works?

How to scroll the outside scrollView not inside scrollView?

I have a scrollView and inside it some scrollViews , and everyone have a webview to show html file, using this method I will zooming every html file , but Now I found that when I scroll the html file it didn't work. I think I scroll the scrollview inside and it autosize the html file , but How to let the scrollview inside not to call the scroll function and when I scroll the html it can call the scroll function outside, and I have disable the scroll property of inside scrollview, but it didn't work, and How to do with it? Thank you very much!
UIScrollView in UIScrollView is a common use. See apple stocks app...
I am trying to send ScrollView Gesture events like pan and zoom from outside the scrollview itself. It doesn't look like apple lets you send to the UIScrollViews handlePan: and handleZoom: methods
A quote from UIScrollView Class reference :-
Important: You should not embed
UIWebView or UITableView objects in
UIScrollView objects. If you do so,
unexpected behavior can result because
touch events for the two objects can
be mixed up and wrongly handled
I would add : "You should not embed UIScrollView objects in UIScrollView "