ScrollView inside View or Vice Versa? - ios

I am working in iOS and cannot find if there is a definitive answer to this.
I have a screen, the entire thing will scroll (not just part of it is scrolling at the top). I am using Storyboards to build this and the content is bigger than the screen size. Is the best way to do this with:
This is all inside of a UIViewController.
The content inside a View (child) inside a fullscreen ScrollView (parent) and set content size of ScrollView as the View's frame.
The content inside a ScrollView (child) inside a fullscreen View (parent) and set content size of ScrollView as its frame and then its new frame as the View's frame.
Just a ScrollView as the first child of the ViewController and set its content size as its frame and then its frame as the screen size (which I would need to check at runtime?)
All of these methods seem to work, but they make other things easier/harder (moving content for keyboard, etc.). Is it simply a matter of opinion or is there a "best/correct" method?

You have to set content size bigger than your view. Then It will scroll.

Related

ios swift - scroll view over image doesn't scroll

I want to have a background image that does not move and have a scrollview over it that allows users to scroll through content while the back image remaining static.
I have tried adding an image to my view and then after a scroll view over it but I'm unable to scroll.
I'm trying to achieve an effect similar to this:
Am I on the right path to achieving this?
You have to set contentSize for UIScrollView. ContentSize has to greater than frame size.

Content in UIScrollView is being cutoff early

I have several UIViews within aUIScrollView and I want them to scroll all the way to the bottom of the UIScrollView before cutting off (See Image #2).
Background on the scroll view:
I created the UIScrollView itself is a subclass of a customUIView. I put the view in a UIScrollView so the auto layout in storyboard creates the correct frame for the device.
In the view controller attached to the storyboard UIViewController I created anIBOutlet to theUIView, and in the viewDidAppear function I called a function attached to the view that populated the UIScrollView.
In the storyboard I gave the view a blue background so I could tell its frame. Here is the what the storyboard looks like:
Then this is what it looks like on my phone:
Notice how much space exists between where the view cuts off and where the bottom of the screen is. It does this on all devices.
I have tried adjusting the bottom content inset. It is currently at 0.0 but I tried to make it -20 and that did not help.
How can I fix this?

iOS Button not clickable after Animating to reveal panel

I have a UIView that has a container view hidden off the frame that I reveal via animation when you click a button. However, once the animation completes I cannot interact with any objects in the frame that just animated into view.
View Hierarchy
View layout
You will note two things about the view layout
the Container view is outside of the normal view frame/bounds
it has a fixed height (those are the constraint likes you see)
I tried expanding the frame height and bounds in order to accommodate the height of the container view, but after the animation I still can't interact with views in the Container.
What do I need to modify to allow interactions to work once this view animates into view?

UIScrollview, other controls, not scrolling

I have an app which shows two images housed within a UIScrollview.
The scrollview is of size (320, 530), underneath it is an imageview size (320,38), this acts like a dock at the bottom of this screen, ( in fact it has to be there at the bottom of all screens in this app).
As it stand the scrollview works fine and the images switch from one to anothr when the user
moves the scrollview.
The problem is, I need the scrollview height to go all the way down ( from 530 to 568), and end up behind the dock imageview, when I change its height and the height of images within it, it just stops scrolling.
Is this impossible in scrollviews? does it have to have all of its screen real estate as top view?
Any solutions for this?
Thanks.
Update :
so I worked on the alpha and the image constraints, and the bottom imnage is located properly,
still the scrolling is not functioning.this is the latest code with changes.
http://ge.tt/4LYJGWl/v/0?c
thanks.
This is certainly possible. Add a full height scroll view to the controller's view, then add the small image view to the bottom. In the scene list at the left move that image view up so it's directly underneath the main view, which will make it a subview of that view rather than the scroll view (you'll then need to move the scroll view up above the image view so the image view will appear on top). You'll probably have to change some constraints to pin it to the bottom, and give it an alpha value less than 1 so the scroll view will show through.
After Edit
This is the screen shot of the scene from your updated code:
You only have one view that's directly under the main view, your scroll view. Compare that to my image.

How can I place a non-scrolling UIView underneath the scroll indicators on a UIScrollView?

I have an application where I'm using a zooming scrollView to do image cropping to a rectangle with a fixed aspect ratio. I have a mask where I darken the parts of the image that will be cropped. Currently I add this subview to the UIScrollView's parent, making them siblings, where this mask is 'higher' than the scrollview. Looks great. Except...
This mask is also masking the scrollIndicators and therefore looks a bit dumb. I could turn off the scrollIndicators, or, ideally, I'd like to place this UIView underneath the scrollIndicators, but not get scrolled with other content, which is what would happen if I made it a subview of the scrollview via [scrollView addSubview: myMaskView];
Anyone know if this is possible?
First, subclass UIScrollView so that you can modify the default behavior of scroll view.
Second create an image view with your image, and put both the image view and your mask view to a scroll view, this way your views will be underneath the scroll indicator.
Third, in your scroll view delegate method viewForZoomingInScrollView:, return your image view, so that only the image view zooms. Note that the scroll view will adjust the content size to be the size of the returned view, but it's fine as long as your image view takes up the whole content size.
And last, override layoutSubviews method, move the mask view to visible bounds of scroll view. The layoutSubviews method is said to be called every frame of scrolling, so the position change won't be visible to end user.
For more details you can refer WWDC session video "Advanced ScrollView Techniques".
EDIT: OK, just found that you can avoid overriding layoutSubviews by implementing the delegate method scrollViewDidScroll.

Resources