Interacting with screen behind UIScrollview - ios

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.

Related

How to handle an UIScrollView in an UIScrollView

I want to use an UIScrollView in an UIScrollView. I think it would be clearer with a
picture
The black border is the border of the screen, the purple is the first UIScrollView and the blue is the second UIScrollView. The arrows show the direction of the scroll.
When I try to put the second UIScrollView in the first with a different scrolling direction, the second show the content twice... I made a video
I have created design for you to explain how to add scroll view inside scroll view.
Here see the following image with constraints.
Note: This is static view not dynamic, This is create to clear concept of ScrollView inside ScrollView. If you are planning to make ScrollView with design then you need to do some more study on AutoLayout with ScrollView.

Putting a UIScrollView inside a UIPageView, scrolling doesn't work

I'm making a pageview that has a bunch of scrollable pages inside it. I have the pageview working, and the viewcontrollers that it rotates each have a scroll view inside them. The problem is, I think, that the scrolling doesn't happen because the touches don't get through to the pageview. The scroll view should only scroll vertically, while the pageview works with the horizontal scrolling. Is it possible to send through only the vertical touches, or is there another way?
Thanks
If you're using a storyboard, open the Attributes inspector of the embedded UIScrollView and deselect the "Shows Horizontal Indicator" option. Do the same on the UIPageViewController, but for the "Shows Vertical Indicator". However, you also have to ensure that the scroll view's contents aren't wider than the scroll view itself; to do this, just constrain the contents' width to be equal to the scroll view's parent.

UIButtons not working in Scroll View

I have a Scroll View with a View (content view) inside of it. I've added two buttons to test. The Scroll View scrolls fine but the buttons within the content view are not clickable. I've seen plenty of posts saying this issue happens when they programmatically add UIButtons to the View, but I am not doing this. Here is my exact process:
Drag the Scroll View onto the main view. Add 4 constraints
Drag the Content View onto the Scroll View. Add 4 constraints.
Add 2 Buttons (one high and one low to test scrolling) to the Content View.
This is all I am doing, no code at this point. Is there anything else I have to do to allow the buttons to be clicked? Here is a screenshot of my xib:
Update:
When hooking the button up to a simple IBAction and logging a message, it turns out it IS being pushed and working properly. However, when the button is pushed, the button isn't changing colors like it should (its "pressed" state is not appearing). Any ideas why?
First make the button to custom type
Select button from storyboard then on right attributed inspector change its "state config" to whatever you need like Highlighted, selected, Disabled and default and choose the colour for each state.
Now you can see the colour change on that button.
A UIScrollView first needs to know whether or not you are going to scroll before letting the touch pass to its child views. If you want the child views to get the touch immediately, set the UIScrollView's delaysContentTouches to NO.

ios A tableview above a scroll view and the button on the scroll view cannot be tapped

I have a UIScrollView on my screen and there are some UIButtons on the scroll view.
I also have a UITableView which is above the scroll view, i.e. the tableview and the scrollview are overlapped.
Why I did this is because I want left and right swipe to flip pages of the scroll view and up/down swipe to show some text on the tableview.
This works fine except the button on the scroll view cannot be tapped. It seems that the tableview "absorbed" the tap event and it did not pass it to the button on the scrollview.
Is there someway to fix this? Thank you.
This could be a solution but I'm not sure of it because from your question I can't understand your problem very well, you can try it but if it doesn't work we will try a different way. Maybe the problem is the arrangement of the UI elements in your Interface Builder/Storyboard. If I correctly understood your situation you have something like this:
To make to UIButtons clickable you have to be sure they're at the highest level of arrangement inside the UIScrollView since the UITableView could cover them and "absorb" [as you said] the touch input. So my suggestion is: arrange your UI elements following the blue arrow in the picture below, placing the UIButtons on top, in this way they'll be 100% clickable.
If I didn't understand your question could you please shoot a picture like the one I've posted so I can understand it better?

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