iOS UICollectionView not scrolling when cell is touched - ios

I've created a simple grid based UICollectionView but I'm having trouble with the scrolling. If I touch the view itself rather than a cell within it then it seems to scroll correctly but if I touch one of the cells and try to scroll then nothing happens. This is a bit of an issue, as I basically want the grid of cells to completely fill the view, and when the view is filled like that there is nowhere to touch that will actually make it scroll! I guess the easiest way to describe what I'm trying to achieve is a table view but with two columns of cells rather than one.
I can't seem to find anything in the documentation that talks about this issue and I've tried various combinations of "user interaction enabled" settings etc.
One final thing, I do require the cells to respond to a single tap touch (basically to toggle them on and off) so I don't want to completely disable them responding to touches.

Related

Keyboard moves UICollectionView cell off screen

so I have created a UICollectionViewController, made each cell the size of the screen and enabled the function to scroll horizontally between the cells like pages.
My problem is whenever the keyboard comes up (as I plan to populate the cells with some input to get from the user) it pushes the content off the screen.
I am not sure how to stop this, and I have looked online but to no avail. The best I could find is this question also on stackoverflow but it doesn't help.

How to drag a row between other rows in UITableView or UICollectionView

I am trying to implement the view shown in the animation below:
I found a great control called TGLStackedViewController which does almost what I need. The way it performs the moving is by taking a snapshot of the card you want to move and adding it as a subview to the collectionView, while hiding the original card. When dragging has stopped the movable view is removed and the original card is made visible again.
This works well, but doesn't produce the result I want since the movable view covers all cards. I wish for the card being moved to always be between the two cells above and below, just like in the animation. But I am not sure how to do this since all items are on the same level. I would really like to avoid making a completely custom view control and if possible do this with either UICollectionView or UITableView.

Is is possible to control the speed and scrolling of a UITableView

I've got custom tableview cells that are 170 px tall. Including the table header I can see two complete cells and a portion of the third. When I scroll the tableview, the cells shift up but do not stop until a portion of the third is above the table.
Is it possible to change the way the table scrolls and allow me to see all of the third cell. A video illustrating the issue is available at https://youtu.be/iuhuR_wDe90
Images of the issue:
It seems you have enabled 'pagination' on your UITableView.
You can get rid of this in Interface Builder, in the Scroll View section there's an option called 'Paging Enabled' which should be switched off.
If you don't use storyboards, tableView.pagingEnabled = NO; will do the trick as well (though it is NO already by default).

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.)

How do I speed up tap handling on a complex UITableView

I have an app with a TableView which is contained inside a ScrollView (horizontal pagination).
In each TableView is a custom TableViewCell which has a number of views.
To handle a singular tap on an area within the cell, I add a UITapGestureRecogniser to views within the cell.
Rendering performance is fine. But when I tap, I notice a sizeable delay from the point of tapping, to the point where the selector is called (i.e. I believe most of the time is being spent inside UIKit doing hitTests and finding out which element responds to what).
Is there a way to make this faster? What should I be looking out for that may be causing this problem?
You could try adding a single tap recognizer to a transparent view that fills the cells contentView, add it last so it's front most in the subViews array, then have it to the hit test for just the views of interest.
That said it would seem the delay comes from some other interaction.

Resources