How to show vertical or horizontal scroller on UIWebView? - iphone

I ma using UIWebView to some html content. And some time the data is more in width or height but I have fixed size UIWebView. So for user perspective I want to show scroller vertical or horizontal to indicate the user that there are some more content are available in this view. I am using
[webView.scrollView flashScrollIndicators];
but it show scroller when I touch UIWebView. I want to show scroller by default. Can you suggest how to do this.

Use the scroll view of the webviw like this:
[(YOUR WEBVIEW).scrollView setShowsHorizontalScrollIndicator:YES];
[(YOUR WEBVIEW)scrollView setShowsVerticalScrollIndicator:YES];
You can do one thing that ,use this
- (void) webViewDidFinishLoad:(UIWebView *)webView){
[(YOUR WEBVIEW).scrollView flashScrollIndicators];
}
It Will show the scroll-indicator when downloading of the content will finish and user will easily understand that , there are more content on the bottom of the page.

The answer here is simple - you can't as it is against the human interface guidelines. There is a reason that the only way you can manually get them to show is by calling flashScrollIndicators. Apple didn't intend for you to show them so if you're going to implement this, it's going to be the hard way (subclassing or creating your own UIWebView).
Appearance and Behavior
When a scroll view first appears—or when users interact with it—vertical or horizontal scroll indicators flash briefly to show users that there is more content they can reveal. Other than the transient scroll indicators, a scroll view has no predefined appearance.
A scroll view responds to the speed and direction of gestures to reveal content in a way that feels natural to people. When users drag content in a scroll view, the content follows the touch; when users flick content, the scroll view reveals the content quickly and stops scrolling when the user touches the screen or when the end of the content is reached. A scroll view can also operate in paging mode, in which each drag or flick gesture reveals one app-defined page of content.
Source - iOS UI Element Usage Guidelines

Related

Unable to click on any part of the UIScrollView to scroll through the images. There is only a specific porition I can click on

I've some UIImages loaded into a UIScrollView.
However, when I try to scroll through these UIImages, I can only click on a specific area in the screen.
What is the property I should look out for to expand the "clickable area"? Such that I can click on any part of the scroll view to start scroll through the images.
Is there anything to do with content size of the scroll view?
Make sure that -userInteractionEnabled is NO for the views you add to your scroll view.
Update:
Set -clipsToBounds to YES and see whether the scrollview's frame is just too small and the content goes beyond the bounds of the view.

Correct approach for implementing vertical scrolling with UIScrollView

I know that I asked a question a few minutes ago, but I want to make a few points clearer before asking for the community's help. I'm new to iOS development, close to finishing my first app. The only thing standing in my way is this UIScrollView. I simply do not understand it, and could use your help.
This is in the detail view controller of a drill-down app with a tab bar. I have approximately 8 fields (for things like phone numbers and such) drawing from a .plist. Obviously, those take up enough room that I could use a little extra real estate. I would guess that it needs to be about the size of two views vertically, but I do not understand how to allocate that sort of space to a UIScrollView. Some tutorials I have read say that you don't even need to define it in the header, which I doubt and do not understand. Additionally, I do not understand how to simply get the app to smoothly scroll up-and down only. Apple's examples have constant move cycles that flip between horizontal pictures.
I doubt it makes very much a difference, but I have an image that is in the background. I'm going to load the view on top of that.
My question is broad, so I don't expect you to take the time to sit down and write out all of the code for me (and I wouldn't ask you to). Just an outline of quick, helpful tips would help me understand how to get this view to load in the context of my project.
Many thanks!
It's fairly simple. Add a UIScrollView to your view. Add your fields and such to the scrollview. In viewDidLoad or somewhere similar, you need to set the contentSize on your scrollview. This is the "virtual" area that will be scrollable. This will generally be larger than the frame of the scrollview. In your case, you indicated it should be roughly double the width.
For instance, if you had a scrollview with a view inside, and you wanted to make sure the entire view is visible via scrolling:
self.scrollView.contentSize = self.contentView.frame.size;
//setting scrollview zoom level
self._scrollview.minimumZoomScale=0.5;
self._scrollview.maximumZoomScale=6.0;
self._scrollview.contentSize=CGSizeMake(320,500 );
you have to outlet scroll view in .h class and #property #synthesis this scroll view.then you can able to scroll up and down,if u want only vertical scrolling ,then u have to go to interface builder and uncheck the horizontal scrolling.
You can set a few settings for your scrollview to limit the scrolling to horizontal or vertical. A few important ones are:
// pseudcode here, start typing "[scrollView " then press escape to get a intelli-sense of all // the things you can set for the scrollview.
// values could be YES/NO or TRUE/FALSE, I can't remember which one but
// I think it's YES/NO. Once you start scrolling, the phone will determine
// which way you're scrolling then lock it to that direction
[scrollView setDirectionalLockEnabled:YES];
// when you slide the view, if enough of the next part of the view is visible,
// the scrollview will snap or bounce the scrollview to fit this new "page".
// think of swiping feature to navigate the iPhone home screens
// to show different "pages" of iphone apps
[scrollView setPagingEnabled:YES];
// as a safe guard, make sure the width of your scrollview fits snuggly with the content
// it is trying to display. If the width is more than necessary to display your table of
// data vertically, sometimes the scrollview will cause the
// horizontal scrolling that you don't want to happen and you get bi-directional scrolling
Just set the content size of UIScrollView after adding all the controls/button/textfields etc. for example you add 10 textfields in UIScrollview then content size of UIScrollView will be
lastTextField.frame.origin.y+lastTextField.frame.size.height+20; 20 is for margin.
That's it let me know if you want to know something more related to your app.

UIWebView Zoom Issue

How can we identify that a user has zoomed the webView so as to resize the other components present. My webView starts from the middle of the screen and when a user zooms the webView it starts to scroll horizontally and vertically but it happens within the webView.The scrolling happens internally. I want to lock the webView from scrolling internally so that when a user scrolls vertically, the labels,textfields etc. on top of the webView also scroll up and not the webView alone. What I want to achieve is pretty similar to iPhone Native Email Client. For accomplishing this, I would like to put this webView on top of a scrollView and when a user zooms it, I would like to reset the content size of my scrollView so that whatever is added to the scrollView like labels and textfields above the webView also scroll when I scroll the webView.
Any ideas?
You could do:
Disallow user to pinch zoom the webview
Detect double tap on your scrollview and toggle webview's scalesPageToFit property AND set userInteractionDisabled on webview
Now you can scroll only scrollview which has all the controls..
You can find help from this
Disabling default zoom effect
and
scalesPageToFit property

UIScrollView - A way to make one scroll view smaller than the other?

In my app, I have part of a view sticking out from the right. I would like the user to be able to swipe that to the left, to pull/reveal the rest of that view, which would basically almost cover the screen. See below:
I am figuring my best option is to use UIScrollView for two reasons. That I can lock the movement to horizontal only, and the animation for swiping is already built it.
My question is, can I have one page of the UIScrollView smaller than the other as shown in my mockup images?
UIScrollView horizontal paging like Mobile Safari tabs

How to make modal view scrollable?

I have a modal view with a textview and a button. When the keyboard is displayed it covers up some of my UI elements. I'd like my modal to be scrollable so that it can be viewed while the keyboard is displayed. How can I do this?
I've had the same question, and i've played with it a bit,
setting a UIScrollView is not enough, as in the inspector
you should 1st. increase it Hight, then in the attributes, check the following checkboxes:
Scrolling enabled, Bounce Scroll, always bounce vertically.
Edited: Forgot the most inportant thing:
in the size inspector, set the Buttom field (under content) to the size you wish, (960 is twice the regular size)
Use a UIScrollView instead of an ordinary UIView. You can disable scrolling when you don't want the user to be able to with:
[theView setScrollEnabled:NO];