Make the UICollectionView scrollable even when its not full - ios

The UICollectionView disables scrolling by default when there is not enough cells in the view. When this occurs I need it to bounce back to position when pulled. Im am aware of a hack where I can fill the UICollectionView with empty tables to enable scrolling but I was hoping there would be a slightly more fluid example as
I don't want the view to scroll but instead to automatically bounce back to its position. This is because of the effect I have implemented below as can see below.
https://youtu.be/r75xB9-Mb4g
Is there a way to achieve this simply, when there is not enough cells in the UICollectionView the scroll is disabled.

For vertical scrolling:
self.collectionView.alwaysBounceVertical = true;
For horizontal scrolling:
self.collectionView.alwaysBounceHorizontal = true;

Related

How to give bounce effect to my Table View in swift

I am working on a project where i have used tableView to list numbers and had to set the tableView height according to its content size and further i have disabled the scroll of tableview to satisfy my design. But the problem is when i have disabled it the bounce effect also got disabled.
Is there is any way to give it a bounce effect and at a time disabling the scroll?
No. The bounce property of the UITableview works when scrolling is enabled.
So it is not possible to work it when scrolling is disabled.
Instead you can increase/decrease the height of the UITableview based on the rows.

UITableView - How to specify start position for horizontal scrolling

Could anybody please help me understand if there is a way to provide the start position for horizontal scrolling in UITableView?
Basically, I have enabled horizontal scrolling by giving content inset like [self.tblData setContentInset:UIEdgeInsetsMake(0,0,0,500)];. But, I do not want the section headers to scroll. Is there a way that I can fix the section headers while scrolling horizontally?
If you want to scroll the view horizontally, i suggest that you should replace UITableView with UICollectionView。
If you want to scroll just one cell horizontally, you can add UIScrollView into cell.contentView.

How can I make UITableView less sensitive to vertical scrolling?

I have table view that has more than 10 rows and inside each row I'm placing a hortizontally-scrolling scrollview (you can thumb through images much like in Coverflow).
The problem is that UITableView is too sensitive to vertical scrolling. When I'm trying to scroll left and right in a particular scrollview (inside of any cell), the table view starts scrolling up or down once it detects even the slightest movement of my finger upon the y-axis.
Is there a way I can change this and set a higher vertical-scroll threshold for the table view?
Here's a couple suggestions. Try them and see how they feel.
Suggestion 1
When you dequeue your tableViewCells, try calling this:
[tableView.panGestureRecognizer requireGestureRecognizerToFail:cell.scrollView.panGestureRecognizer];
Suggestion 2
Try setting this on your tableView:
self.tableView.delaysContentTouches = NO;
That property defaults to YES. It delays touches to the content of the table view cells by a fraction of a second, to help it recognize the difference between a tap and a drag.

UITableViewCell Reuse issues with horizontal tableview

I have a slightly complicated system that I am having some reuse issues with, wanted to get some feedback. Basically it is a vertical tableview, and each cell contains another tableview that is rotated 90 degrees, so that each cell scrolls horizontally. Each horizontal cell is also set up to scroll infinitely with paginated responses from an API. I am having issues where cells are copying on top of each other when the vertical table is scrolled down. I have reuse identifiers set up correctly and in each of the horizontal tableviews I am running the following:
- (void)prepareForReuse
{
[_horizontalTableView reloadData];
}
If I turn off reusing cells the issue doesn't happen, but the vertical scrolling performance suffers. I am wondering if its possible that reusing cells in this type of a set up just isnt possible? Any experience with this is helpful. Thanks.
This is not a direct way to solve your issue, but I believe if you use a horizontal scroll view inside each vertical cell, you will have this done faster and with less weird behaviours. I also believe this is not a standard way, so weird stuff will happen.
All you do is set or extend the content size of the scroll off screen continuously to create an infinite scrolling behaviour. Create views within the scroll view pragmatically to simulate each cell. Hope this helps.

How do I prevent a scroll view from letting a user (temporarily) scroll a UIScrollView out of it's content area?

UIScroll view lets me declared a scrollable area when I have too much content for one page. Strangely, the scroll view in question behaves as desired in the X-axis, with no scrolling whatsoever allowed. Unfortunately, the Y axis -- where scrolling is necessary -- doesn't 'clip' the allowed scroll area to the content size. The user can scroll outside of the content size, and only after they let go does scroll view 'bounce' back to the allowed zone.
I want to prevent the user from scrolling further up than there is content to view (down doesn't bother me) because it looks 'wrong' to have the header at the top of the scroll view pull down, leaving the regular background behind it.
If you are making your UIScrollView in interface this is as simple as deselecting the
"Bounces, Bounces Horizontally, and Bounces Vertically"
check boxes in your scrollView's attributes. If you are designing the UIScrollView in code you can add this.
self.textView.alwaysBounceHorizontal = NO;
self.textView.alwaysBounceVertical = NO;
self.textView.bounces = NO;

Resources