Slide up view in a horizontal UIScrollView? - ios

I currently have a horizontal scrollview where the next content is partially displayed. For some of these views, they need to be able to pull up and expose more content. What's the best way to build this sort of interaction? I see that I can capture scrollview events via the scrollview delegate, but I'm not sure where to go from there.

Extend the scrollview height up to whatever height you want the view to be able to move to/expand.
Then, add a UIPanGestureRecognizer to the scrollview, and detect when the movement is 'up', and move the views as necessary.

Related

Interacting with screen behind UIScrollview

I have a view where content is supposed to scroll over a few elements. One of which is a button. What I did is place the button and all background elements, and then created a scrollview on top of that.
However, the touch events now (obviously) go to the scrollview, and not to the elements in the back. Is it possible to enable interaction through the empty parts of a scroll view?
Screenshot here:
There is a scrollview on top of e.g. the "next" and "edit" buttons. but I'd like these to be clickable anyways.
Thanks.
I'm going to assume that the content you want to scroll is in a subview. ScrollViews always serve as the first layer of any scrollable UI. Put scrollview in your subview then UIView over your ScrollView and over that add your elements.

Which the better way to make carousel view in swift with open - animation (expanding)?

I need to make carousel view in swift with "opening-animation".
First of all, I have created scroll view, after that have created subViews with my customView, maked my scrollView paged-enabled, and it's okay, but I need to make it expanding by swipe gesture. I added animation, but this view can't be higher than scrollView height, so I need to make this width and height (after gesture) like viewController's view height and width. And, it's the problem.
What's better way to do this?
Example screen:
BeforeGesture
Second example screen: after up-swipe gesture
I think you will need to handle it using the UIPanGestureRecognizer gesture which will give you the better control on all the different states of pan (drag began, drag ended). In your drag ended state you can handle the logic of increasing the height of scrollview and after that add the animation to show the expanded view with animation effect.
Let me know if you need any further help.

How to horizontally scroll between pages of controls in UIScrollView iOS/Swift

I am trying to find the way to implement a scroll view on my viewController screen, which allows the user to scroll between different pages of controls and have the controls around it, outside the scroll view, react to whatever data or actions take place in the scroll view.
All the tutorials I have found is adding a scroll view that shows a carousel of images, or programmatically adding coloured frames. Very little control interaction.
But none that shows how to create 2-3 pages of controls (buttons and labels), and how to integrate it with the parent view (so the parent view and scroll view talk to each other in one view).
So for now, what would be the first step to create a scroll view with 2 'pages' of controls? Has anyone come across any good resources for this? How is the best way to achieve this?
Thanks!
Add Scroll View. Add top,left,right, bottom constraint to scroll view. Set horizontal only in storyboard.
Add a view inside scroll view. Now add height constraint from this view to super view. (Not the scroll view.) Specify some width and add width constraint.
I suggest you to use UIPageViewController for this type of scrolling.
I suggest you go for UICollectionViewLayout and enable paging to true. Using this will give you the finest control of each page and the horizontal as well as vertical scroll.

Using vertical UIScrollView with horizontal paging

So, what I need: 3 pages (with swipe support): two of them just fit the screen, third one must have vertical scrolling.
1) Can you provide what bunch of controls I need to use: ScrollView with vertical scrolling inside parent ScrollView with paging enabled? Or ScrollView with PageControl?
2) How to adjust vertical ScrollView. I've read bunch of question here, and tried to do that by myself.
I tried to add 4 constraints for ScrollView (pin it to parent edges), then I add child UIView, also pin it to Scroll edges. Then I add some rectangles to child view, and using different settings I got: just horizontal view, horizontal+vertical scroll, only vertical scroll but with top space from UINavigationBar and with clipped some height from child rectangles (I can't scroll to them).
Can someone provide some example of how to do that? I prefer IB for constraints, but if it's necessary to calculate some math in code - it's ok.
Thanks
When paging between view's like that, I would suggest using a UIPageController (You can easily get a sample application by creating a new project and selecting "Page Based Application"). Change the transition style from Page Curl to Scrolling and there is the functionality you need for paging between view controllers. Now you just can place a scroll view in your third view controller and make sure the attributes are as follows. DirectionLockEnabled is the key to what you are trying to do, as it determines if scrolling is disabled in a particular direction (this case horizontal scrolling). Using this type of solution, it is then really easy to set constraints because you're setting constraints for 3 separate view controllers rather than 3 views within a scroll view
edit: disable "Shows Horizontal Indicator" Checkbox also

UIScrollview, how to scroll a page under another window

I have a UISCrollview loading webviews, as the user starts scrolling to go to the next page, I need to have the the coming webpage to scroll into the screen from underneath another UIView that is stationary, I tried changing the alpha but its not really what I am looking for. how can I accomplish that?
For example, the scroll direction is top to bottom, now I have a uiview at the top of the screen which has some static data showing ( title, location, and other text labels ), and as the user scrolls down I want the content to scroll underneath the label ui view. Hope this clarifies it.
If I understand this question correctly I'd say you can't do this with a UIScrollView. Instead, you could have separate views for each UIWebView and handle the panning of one view under another with a UIPanGestureRecognizer.
Also, did you know there can be conflicts when using UIWebView's inside UIScrollView's?

Resources