I have two UIScrollViews, one is horizental, the other is like page on the horizontal view. I want to click the status bar and have the vertical scrollView scroll to the top, but it doesn't work.
I searched for some information that said I must set UIScrollView.scrollsToTop=NO, but it doesn't work. Could somebody tell me why?
The scroll view only scrolls to the top if there is a single scroll view present with the scrollsToTop property set to YES.
Make sure it's set to NO on your horizontal scroll view and all the child, vertical scroll views contained within. Then, using the horizontal scroll view's delegate, as one vertical scroll view leaves the visible area, toggle the property to NO and toggle the incoming vertical scroll view's property to YES.
Related
How Can I make the green area of the screen shot of my app be able to scroll with the paging animation and page indicators?I would like for me to add more icon-buttons to it with keeping the header the same size.
First you need a scroll view and your view has to be inside of the scroll view.
Then you need to enable paging on the scroll view
[scrollView setPagingEnabled:YES];
If the value of this property is YES, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. The default value is NO.
If you want to have page indicators you need to use UIPageControlwhich you will have to manage yourself as far as I know. You could always check after scrolling (see UIScrollViewDelegate ) which page you are on based on the contentOffset property of the scroll view.
I am looking for a way so that when I swipe left or right on a horizontal scroll view it will snap to one of the elements in the center, assuming that three elements (in this case a UIImageView) will be shown at once. How do I do this?
Turn on the pagingEnabled property for UIScrollView
If the value of this property is YES, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. The default value is NO.
You can set it programatically or in interface builder.
I'm trying to add a scroll view to an existing screen of my app to help scroll the screen upward when keyboard hides a text field into this view.
I have added the scroll view as a subview of the main view in Interface Builder. Then I added all other objects as subviews to this scrollview. I have set the scroll view size to 320x460 with x=0 and y=0. Now, I notice the layout is broken and all objects (labels,text fields overlap in the same place).
Do you know the proper way to position this scrollview in interface builder so that I can easily position the other objects?
Thx for helping,
Stephane
What you did is correct. It sounds like you moved the other UI elements into the scroll view after you positioned them. In this case they would default to the center position and be overlapped.
If you find it difficult to use dragging in Xcode's Interface Builder, try the position and size tab and type in the coordinates. Alternatively, reposition your UI elements in code.
I have a view with half a dozen text fields and labels, and a button.
I want it to be that when the keyboard pops up, the view becomes scrollable, so you can scroll the view up and see the bottom half of the fields without having to dismiss the keyboard to get to them.
Just putting it inside a UIScrollView doesn't seem to do it.
You have to set the scroll view's contentSize to enable scrolling.
Let's say, i have two tableview inside a scrollview. After i scrolled up & down tableview1, and then touch and swipe to scroll the scrollview horizontally to tableview2, i want tableview2 to have the same vertical (up & down) position as tableview1. is there any way to achieve that?
thanks
You can put code in the UITableViews' viewWillDisplay: methods that grabs the other table view's scroll position (called a "content offset" in scroll view parlance) and calls setContentOffset:animated:. This way, whenever either scroll view will appear on the screen, it will automatically scroll to the other view's position.