UIScrollView bounces when content is smaller than view's size - iphone

How can I simply let the scrollview bounce, when the content size is smaller than the view's frame and when I drag it?
like iPhone's app search results.

see UIScrollView (paging mode) bounces only when there two or more pages?
you'd better set the property:
scroll.alwaysBounceVertical = YES;
scroll.alwaysBounceHorizontal = YES;

answer myself: the simplest way would be to set the height of the content size to be the height of the frame plus 1. kind of stupid but according to document it only scrolls when size is bigger than frame.

If you prefer .xib just check Bounce Vertically.

Related

iPhone Infinite Vertical Text Scrolling [duplicate]

I have a UIScrollView of size 320*460 and with content size 1024*1024.
I can place 25 images of 256*256 in it with the 13th picture shown at the centre of the
screen when it loades with bits of surrounding pictures around it.
When i swipe to any side I want it to appear just like the mapView. With new images
appearing and showing.
How can I do it?
It's very easy & somewhat tricky...
You don't need to define the specific size for the ScrollView.....
Generally we use to define ....as per the Examples of Apple
//#define SCROLLVIEW_CONTENT_HEIGHT 460
//#define SCROLLVIEW_CONTENT_WIDTH 320
which is of no use...if you need the infinite height..
just set the height of the ScrollView dynamically as per the Objects added to the ScrollView....
No need to set the predefined height for this...take the dynamic height....
scrollview.contentSize = CGSizeMake(320, txtView.contentSize.height+450);
CGPoint topOffset = CGPointMake(0,0);
[scrollview setContentOffset:topOffset animated:YES];
Hope this will surely work for you..
Good Luck :)
Checkout the sample code called 'Tiling'. It might be what you're looking for.
When scrolling stops, couldn't you just adjust the bounds so that you are now "re-centered" with your new offset?
Presumably you can't scroll more than so many pixels before your finger hits the edge of the screen, so you only need bounds that a few hundred pixels outside the original center.
Once you have a new center, adjust your bounds accordingly, retiling as necessary.

How do i have different UITextViews on the same DetailView without having scrolling problem?

I have DetailView in which there are three textviews which are showing different informations. is it possible that on whenever i scroll down to read all information. all those textviews scroll like they are one page. i mean they look like one textview. i m doing this bcz i need those information in different fonts. and if there is any other nice approach i can use to show that information? plz tell me.
thanx in advance.
Yes, you can place those three UITextViews into a UIScrollView, set userInteractionEnabled = NO in the UITextViews, and properly set the contentSize of the UIScrollView to cover all 3 UITextField size, then they will all scroll as one unit and the UITextViews won't scroll at all within themselves. (Again: a UIScrollView will not scroll in height / width unless the contentSize property's height / width is larger than its frame property height / width).

UIScrollView autoresizing content?

If I set UIScrollView height to self.view.frame.size.height and setAutoresizingMask:UIViewAutoresizingFlexibleHeight then when the view loads the UITabBarController and the UINavigationBar the scroll view frame resizes to suit.
However the content size (set at: self.view.frame.size.height) doesn't change. Fair enough I guess - i can't seem to find an autoresizing option for that, so why would it autoresize.
My fix is to just set the content size as less than the frame height, thus the content will always be the height of the frame. (eg: set content size height to 10points).
I'm just wondering if this is the best way to go about this, or if there's a better way? I'm doing this code in viewDidLoad.
Thanks
Tom
The UIScrollView's contentSize property define the size of the view displayed for Span&Zoom. It normally does not have any relation with the container (i.e. scrollview) size but if you really need to resize the content according to the scrollview size, you can overload the layoutSubViews method to do so.

iphone, need to put many text boxes on the view, how to scroll down to view more content?

iphone, need to put many text boxes on the view, how to scroll down to view more content? I actually put buttons and labels on the ScrollView, but the scrolling doesn't work. Do I need to write any code for that, any example?
Thanks.
You need to set the contentSize property of the UIScrollView to something bigger than its frame size.
[aScrollView setContentSize:CGSizeMake(320, 1000)];

How to create a UIScrollView of infinite scrolling?

I have a UIScrollView of size 320*460 and with content size 1024*1024.
I can place 25 images of 256*256 in it with the 13th picture shown at the centre of the
screen when it loades with bits of surrounding pictures around it.
When i swipe to any side I want it to appear just like the mapView. With new images
appearing and showing.
How can I do it?
It's very easy & somewhat tricky...
You don't need to define the specific size for the ScrollView.....
Generally we use to define ....as per the Examples of Apple
//#define SCROLLVIEW_CONTENT_HEIGHT 460
//#define SCROLLVIEW_CONTENT_WIDTH 320
which is of no use...if you need the infinite height..
just set the height of the ScrollView dynamically as per the Objects added to the ScrollView....
No need to set the predefined height for this...take the dynamic height....
scrollview.contentSize = CGSizeMake(320, txtView.contentSize.height+450);
CGPoint topOffset = CGPointMake(0,0);
[scrollview setContentOffset:topOffset animated:YES];
Hope this will surely work for you..
Good Luck :)
Checkout the sample code called 'Tiling'. It might be what you're looking for.
When scrolling stops, couldn't you just adjust the bounds so that you are now "re-centered" with your new offset?
Presumably you can't scroll more than so many pixels before your finger hits the edge of the screen, so you only need bounds that a few hundred pixels outside the original center.
Once you have a new center, adjust your bounds accordingly, retiling as necessary.