I want to put my UIView inside of UICollectionView(on top) that on scroll it scrolls with UICollectionView content. It's possible to put it on header part in UITableView, I did it, but in UICollectionView I cannot achieve the same effect. How can I do it?
I have created GitHub repo with sample. If anyone could help me with it.
In UITableView I add UIView inside of UITableView and it stays there, but in UICollectionView it stays behind of UICollectionView. I want that it(UICollectionView sections) will stay under the UIView and on scroll all(UIView & UICollectionView sections) will scroll together.
There is no such thing as collection view footer or header, because the layout can be very different depending on your needs, but, you have a couple of function that can help you for example:
registerClass(_:forSupplementaryViewOfKind:withReuseIdentifier:)
or
registerNib(_:forSupplementaryViewOfKind:withReuseIdentifier:)
depending if you are using a nib file or not.
I'm not sure but you will also need to provide the height of the view in the layout delegate
UICollectionViewDelegateFlowLayout
you can do this by dragging your UIView on to your cellidentifier of UICOllectionView
Like i did see in snapshot:
here View is my UIView which i added to UICollectionView and it scroll with the CollectionView
Related
I have UICollectionView inside Static UITableView Cell. I want to ask how to enable vertical scrolling in UIcollectionView interface builder. what are the right settings to achieve that?
You couldn't see any scrolling in the Interface Builder:) Only when compiled.
Yes, you have right set - Scroll direction to Vertical. But... I guess, this is doesn't work for you?
If you set custom layout for collection view in code - you have to setup it.
I need to add a scrollview within a collectionViewCell. This is confusing me because there are essentially two ways of scrolling. You can either scroll from one collectionView cell to the next or within a collectionView Cell itself, to get more info from inside the cell. I have attached a picture of what my collectionView cell looks like right now. I would like for the scrollview to scroll within the gray view. How should I set this up in my interface builder?
Thanks so much!
I have also attached the current heirarchy for my scrollview *Scrolling functionality is not working at the moment.
You have a custom collection view cell already just add a scrollView and then anything you want to display in the cell. So your hierarchy would be something like this :
Custom-Cell: ContentView > UIScrollView > then anything you want to add in the view.
I have UITableViewController with 1 section and header with UISegmentedControl inside.
If user presses first segment we should display UITableView cells
If user presses second segment we should display custom vertical scrolling collection grid with collection items below that header
possible solutions:
change UITableViewController to UICollectionViewController, and UITableViewCells to UICollectionViewCells. This should work but I'm trying to avoid this solution
UICollectionView embedded in UITableViewCell. Setting UICollectionView scrolling enabled to false, adjusting UITableViewCell's height to fit entire UICollectionView's contentSize.height. In systemLayoutSizeFitting(...) method of container (UITableViewCell) we call layoutIfNeeded on container and on contained UICollectionView and return UICollectionView's contentSize.
problem:
(re)calculation of entire UICollectionView contentSize requires a lot of work if we have hundreds of items (cellForItemAtIndexPath for every item). Want to avoid this somehow. Maybe we can increase container (UITableViewCell) height during scrolling UICollectionView which is embedded inside.
Same as 2 but we have fixed size container UITableViewCell (same height as view without header) with UICollectionView inside. When we scroll UITableView to the very bottom UICollectionView scroll should continue scrolling.
problem:
I don't understand how to deal with 2 instances of UIScrollView with scrollingEnabled = true for both. I think this could be solved with pan gesture recognizer delegates. If it is so I need help here.
I would personally opt for number 1 and completely avoid number 2. For number 3, you could set tableView.scrollingEnabled = false when the second segment is tapped. Set it to true when the first segment is tapped. That way, when it's false, the UICollectionView in your UITableViewCell can still scroll.
This tutorial may help with putting a UICollectionView in a UITableViewCell.
I want to add a footer to the UITableView, there are two ways, either footer for the section, or footer for the UITableView. Both don't work for me because I want to footer always at the bottom of the screen. In other words, floating footer.
That's why after searching, people suggest to but the footer under the UITableView. I would need to resize the UITableView and add the footer through IB under it. That makes sense and that's what I am asking for.
Kindly I have a specific problem and It's not about footer at all
My problem is that I couldn't create constrains for the UITableView that locates inside UITableViewContoller, whenever I click Ctrl + drag, I don't see the options that I would normally see.
Is that because I'm working with UITableViewController?
This is a screenshot of my hirechy
Again I would like to resay that my problem is not about footers, my problem is about how to resize the UITableView in a UITableViewController
I created a sample project with a fixed footer. You can download it here. What I have added is:
ContainerView 100%
- TableView 90% of the ContainerView and constraints to the ContainerView
- View 10% of the ContainerView and constraints to the ContainerView
You shouldn't resize the UITableView of an UITableViewController object : your tableview is in fact your main view.
If you want to put a empty space that can't be scrolled below an UITableView, you should use an UIViewController instead.
Add an UITableView and an UIView to this UIViewController object.
Set the left, right, and bottom constraints aligned to its superview for the UIView, and fix its height with a fourth constraint. Add the left, right and top constraints aligned to its superview for the UITableView, and set the vertical space between the view and the tableview to 0 with a constraint.
Yes, you are correct. You cannot add a footer on a UITableViewController. For this I recommend using a UIViewController.
Follow these steps if you want to add a footer:
create UIViewController
Add footer to the bottom and add constraints to the bottom border.
Add UITableView to the UIView, and add constraints to the footer.
Also for the controller, just create two classes within the same file, and make one of them as a UITableViewController and the footer as regular class within the file.
If you just want space you should just use UIViewController. Add UITableView inside that, and put constraints on that.
This is one approach, and there maybe many other. Please let me know if I can help you any further.
I love overcast and am getting into iOS development. I see this style of screen a lot.
From what I gather this is a table view with cells and then headers but how is the part at the bottom added in and also the subtitle pieces of text below each row.
I can't seem to find a way in storyboard to do this.
You can drag a UIView object into your UITableView instance in Interface Builder and then configure it the way that you want to.
When you drag a UIView into your UITableView, just drag it to the top, just above the top-most UITableViewCell in your UITableView to create a header. To create a footer, just drag it below the intended UITableViewCell. You can then resize the view and lay it out to your content.
Also, if you would like to do it programmatically, have a look at the UITableViewHeaderFooterView.
You can also create header views and footer views for sections by implementing methods of the UITableViewDelegate protocol such as: tableView:viewForHeaderInSection: and tableView:viewForFooterInSection:.