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.
Related
I'm currently making a drawing application in Swift, but I wanted the page to be able to expand if the user wanted more room. I figured that I would use a UIScrollView to scroll around the canvas, but I wanted it to expand whenever the user went to the edge of the page, and for the UIImageView that I am drawing on to expand with it. Does anyone know how I would go about doing this?
Thanks!
In storyboard, drag a UIView into your UIScrollView then constrain that view to all sides of the scroll view. Then set the width to whichever value you would like (I would recommend to control drag from your view to the root view of the view controller and select equal widths), then give it a height constraint. Next, you need to connect an IBOutlet to your view controller code for the height constraint you set on the content view inside the scroll view. When you need to extend the page, add to the value of the height constraint and call layoutIfNeeded() on the scroll view.
How to change UITableView's scroll indicator's color? I just need to set it's color. Don't propose change it's style to black or white.
There is not a public API for doing that. Any recommendation that would be given would be likely to be broken when Apple makes changes to the underlying structure of the scroll view.
That does not, however, preclude you from creating your own scroll indicator from scratch. I needed to do this in a particular use case where a scroll indicator needed to be visible at all times, not just when the user was touching the scroll view.
You can have your custom scroll indicator view and position it where it needs to be based upon the content offset of the scroll view and its scroll indicator insets. Adding a handler in scrollViewDidScroll: would then allow you to correctly position it and take advantage of any inertia that the scroll view has.
You can even contract the size of the scroll indicator view based on how far the user has scrolled beyond the content size of the scroll view, to give the same effect of bouncing that Apple's implementation has.
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.
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.
When you have a sectioned, plain-style tableview on the iPhone, such as in the Contacts app, the section headers remain visible when you scroll past them until they are pushed offscreen by the next section header.
Does anyone know how to achieve something like this in an ordinary scrollview? I already have one scrollview nested in another to get horizontal paging with vertical smooth-scrolling, so I'm reluctant to add a third scrollview.
Cheers
Basically I did a bunch of maths in scrollViewDidScroll: and set the frame of the subview.
Edit:
Well my exact requirements were a bit different than the question I asked, I have a footer view as opposed to a header view. Basically in scrollViewDidScroll I have:
CGRect frame = self.footerView.frame;
frame.origin.y = MIN(self.bounds.size.height -
self.footerView.frame.size.height +
self.contentOffset.y,
self.contentSize.height);
self.footerView.frame = frame;
This ensures the footer view, which is a subview of the scroll view, is always visible at the bottom of the scroll view, and there is never a gap between the footer view and the bottom of the content view.