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

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?

Related

Smaller button over a big button in swift

I am new to swift and iOS development. I have created a scroll view with table view cells and image views inside cells. Each Image view has a button with same constraints. I have a fixed button in the same screen (irrespective of scroll view) and I am not sure how to achieve the click for it since every time I click on it, the background button is being clicked. I saw some solutions about disabling and enabling the buttons but in this case, I will not be sure which button will be in the background since it is a scroll view. Any help on how to solve this will be appreciated
Since I don't see your code, I can't tell you the exact fix but I assume that the question is how to determine the button's position in the parent view hierarchy. Every UIView has a method called bringSubviewToFront(view:) so if this was the case, then, you can use this method to bring your button to the front.

iOS 11 navigationbar scroll

so, the setup looks like this:
I want to have one navigationbar and three collectionViews. I want to be able to horizontally scroll through the collectionviews and on vertical scroll the navigationBar large title animation should trigger as well.
What I have tried:
My first try was to create one horizontally.scrolling collectionView with cells having the size of the whole view and in each cell there would be another collectionView that would scroll vertically. Now, that worked great for my purpose but the large title stayed the same size - which, as I understand, is because it does not receive any vertical scroll events since my collectionViews for vertical scrolling are embedded in main collectionView.
It looked like this: https://giphy.com/gifs/50hYRx71XSdYA/html5
Then I tried a different approach. I created pageViewController and two viewControllers both with one vertically-scrolling collectionView. And ... it did not work either. This time if there was pageCurl animation, the navigation title DID animate - but I do not want a pageCurl animation, you can see that here: https://giphy.com/gifs/jFmOpEtUOyxtC/html5
Changing the animation to .scroll just disabled the title animation: https://giphy.com/gifs/l0IsGVhKKb0lzomqc/html5
I can not find a way to do this, do any of you have any idea?
Thanks!
Unfortunately the new self-collapsing navigation bar is using some private Apple-magic in the background to hook into the top-level scroll view of the view controller, therefore you cannot use this mechanism the way you've described.

Create Shazam Type UI ios Swift

I am trying to recreate a UIView I have seen in multiple apps, mainly Shazam. The top half of the screen has some interactive buttons, and the bottom half looks like a tableView with custom cells. When the bottom half is panned/swiped up, the tableView scrolls over the top half with velocity, much like a scroll view.
I have been researching this and experimenting for a couple days now. I have gotten close, but not quite there.
My last approach was a view that had a tableView inside it. When the view was panned, the view would move to wherever the finger moved it to, but then would not have any velocity afterwards. Also when the tableView was panned/swiped down, it wouldn't move the whole view down.
Before that I tried a scrollView that took up the whole length of the screen. That gave the desired effect, but the button wasn’t tappable, and you could scroll the view in the button area, which is undesired.
Does it utilize ScrollViews or is it using a tableView that acts much like a ScrollView somehow.
Here is the Shazam UI/UX I am looking to recreate:
The top portion has interactive buttons, and doesn’t scroll. The bottom half shows content and when scrolled, covers up the top portion.
Below is what I have tried so far: This one is the panning view, which sort of works, but doesn’t have velocity and the tableView doesn’t scroll the view back down.
Any thoughts on a direction I can take from here is greatly appreciated. I am using Swift.
Cheers
This sort of thing is perhaps best done with a collection view and a custom layout — you can have some items for which you set layout attributes absolute to the view, and others relative to the scroll content offset.
There's a great (if wandering) discussion of this and other techniques in the Advanced User Interfaces with Collection Views talk from WWDC 2014.
This is actually simple than it seems at first. Here's how you can achieve this:
Create a UIViewController (not a UITableViewController).
Add some buttons to the top area of the screen.
Add a table view spanning the entire view controller's view. Make sure the table view is on top of the buttons added in the previous step.
Configure the top cell of the table view to be transparent (by setting its background color to Clear). Set the background color on the table view to Clear as well. This way it won't obscure the elements at the top of the screen, unless the table is scrolled up.
Because your table view is now transparent, you'll need to explicitly set the background color on the table cells other than the top one.
Profit!

Scroll a view except a part of it

I want a screen with scroll, and I want to scroll until a part of the view. When I reach this, this part will be fixed on the top and you can go on scrolling. In the image:
You begin scrolling until the buttons part, then, the buttons stay fixed in the top and you can scroll more. It's like the spotify app effect in the lists, more or less, if you know it.
Thank you in advance
You could probably achieve this by implementing the -scrollViewDidScroll: method in your scroll view's delegate. When the view scrolls, check the offset to see if the button is visible. If it is, and if it's close to the correct position, you could remove it from the scroll view and position it above the scroll view in the position you want.

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