Swipe does not work with UITableview's scrollview and Pull to Refresh in iOS - ios

I have created UITableView with Scrollview and given swipe gesture to swipe from left to right and vice-versa between three different views. Both of them don't seem to work with each other. On top of this I have a pull to refresh functionality on the UITableView. I have tried to implement UIGestureRecogniser delegate method but it doesn't seem to work.Any Suggestions?
I have realised that when the bouncing is disabled on the scrollview the swipe functionality works fine, but Pull-to-refresh does not work in this case.

Related

UITableView scroll at top issue iOS

I have a tableview and I would like to know when user scroll at top and if in those moment the tableview is not at top (for example its at middle) I just implement the delegate method scrollViewDidScroll and check the value of content offset and its ok.
My problem is when the tableview is is already at the top and scrollViewDidScroll is not called (I want to know if the user do the gesture for scroll to the top even if it is already at the top).
For this reason I thought to add a pan gesture to tableview but I saw that create problems about scrolling and the implementation is cumbersome.
I ask to you if you know another way to achieve this or the only way is adding pan gesture.
You should try to use scrollViewWillBeginDragging or scrollViewWillEndDragging

multiple view controllers with tableview inside scrollview

I have 3 viewcontrollers inside a UIScrollView that page horizontally. each viewcontroller has a tableview within it.
I can swipe between the 3 viewcontrollers easily when the active table is still (not scrolling) - but when i try to page left or right when the tableview is moving it seems to ignore the touch and gets stuck. I have to stop the tableview with a touch before paging (almost as if the tableview is trying to receive the horizontal gesture)
how can I make my scrollview always react to a horizontal paging
here is a visual of my setup:
tell me if you need any more info
There are multiple ways to get around this.
One way is that you could manage the horizontal scrolling yourself with UIGestureRecognizer. So if there is a left swipe then scroll horizontally to the left and vice versa for right swipe. That way if a UITableViewController is vertically scrolling at the time of the horizontal swipe, it won't have to wait until it is stopped to detect it.

UIScrollView - scroll or swipe?

In my app I have a UIScrollView and I need to swipe left and right from one picture to the next, but I also need to recognize a scroll.
How do I differentiate between a scroll and a swipe with UIScrollView?
I believe you're actually looking for is an implementation of UIScrollView with Paging, as you do not need to handle the touch events yourself, or determine if they are scrolls or swipes.
The Apple Documentation on Scroll Views and Paging Mode should help you get started
Look into the UIScrollView Delegate Methods. ScrollView can detect different types of actions drag etc or add swipeGesture directly to the scroll view
StackOverflow has questions already on this
iOS: UIScrollView detecting Swipe Gesture
Setting up UIScrollView to swipe between 3 view controllers
How to recognize swipe gesture in UIScrollView

UITableViewCell Editing is very difficult to show

I want my table view cell to show the Delete bar on the right side when the user swipes. However, the table view is in a UIScrollView, and although it is at the far right side, and swiping left does not move the scroll view, the table view cell makes it difficult to edit.
In order to trigger the swipe for editing, I must swipe very fast and in a perfectly horizontal line. The speed required is far more than you can expect users to even want to do, and would not be expected at all from a user's perspective.
I believe the scroll view is the cause, but I cannot be certain. No gesture recognizer is present.
How can I prevent the scroll view from mucking up this experience?
Putting a tableView or webView in a scrollView is not advised, because of the exact problem you are having. Your best bet is to find a way around putting it in a scrollView. Other than modifying your tableView to not be in the scrollView, you might try moving your tableView to the front. [superView bringSubviewToFront:tableView]; hope this helps.
You could try using the gesture recognizer delegate methods for this. I don't have Xcode in front of me, but if you use gestureRecognizer:shouldRequireFailureOfGestureRecognizer: and just fail the scrollView's swiping gesture if the gesture recognized is that of the swiping of the table view cell. Check UIGestureRecognizerDelegate in the docs.

Swipe to delete UITableViewCell very difficult to trigger

So I have a table view and I'd like the user to be able to swipe left to reveal a delete button, identically to how it works in the mail app. My issue is not that I can't get this to work - it does, I can swipe the row left, it reveals a delete button, and the user can click it to delete the cell (I do this by implementing editingStyleForRowAtIndexPath). My issue is that the swipe that is required is extremely insensitive. You have to swipe very fast and perfectly horizontally. It is not nearly as smooth as the swiping in mail. Is this just the way it is or am I overlooking something?
I thought maybe the views in the cell were blocking the swipe gesture somehow, but I went into the xib and set everything to hidden and it still is extremely difficult to swipe. The other thing I tried was to add my own swipe gesture recognizer to trigger the delete show. I tried adding it to the cell (that didn't work), to the table view (nope), and I also tried adding a clear colored UIView as a frontmost subview and putting it on that, but still no. Any ideas?
EDIT:
I just created a new project to test the responsiveness of the editing style delete feature - very very simple table view just to see how it works. It is MUCH easier to swipe than the cell in my actual project. There aren't many differences between my test project and my actual one: actual loads a xib on cellForRowAtIndexPath while in test project it uses default styled cell, actual project has imageviews and uilabels within cell while test project is just a uilabel... what could be making it so unresponsive?
It turns out there was a competing gesture recognizer hidden in a superclass I was completely oblivious to. Once I realized that, it was easily solved by disabling the other recognizer for that screen (although I believe there would be a more correct way of doing it by setting gesture recognizer priorities). Anyway, if you are having similar issues - really strange/ unexpected behavior from a UIGestureRecognizer - I would ensure there is no other gesture recognizer interfering.
You could try to "roll your own". In the built-in UITableView, we are probably responding to a leftward swipe gesture recognizer (the gesture for which, as you say, must be quick and very horizontal in order to recognized). The way this works in Mail, on the other hand, is that the cell contents actually contains a UIScrollView, capable of being scrolled horizontally only - and that is what you are doing when you slide left, just dragging as you would with any scroll view. (That's why you can peek at the Delete button and then drag the message back to the right.)

Resources