brightec / customcollectionviewlayout Goto Github PK
View Code? Open in Web Editor NEWCustom layout for a collection view using horizontal and vertical scrolling with sticky rows and columns
License: MIT License
Custom layout for a collection view using horizontal and vertical scrolling with sticky rows and columns
License: MIT License
any updates for swift 2 ?
how to add dynamic rows and columns in CustomCollectionViewLayout class
It is a great library i integrated it and work properly but there is an issue that i want them to scroll the row either horizontal or vertical at one time (when user move its finger diagonally it scroll both the rows),can you please tell me how to stop this behaviour on diagonal scroll as i am very thankful to you.
When i have more than 7 sections or rows in the collection view, if I scroll the collectionview up and down, i see that the cell content in the second,third and fourth section are getting misplaced or going blank. The header row that is fixed does not have any issues.
How do we resolve this.
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 0
}
This is required if datasource is coming form server. First time view refreshes with 0 sections, before response arrive from the server.
Hello,
I'm trying to open a new viewcontroller on item selection.
If I add an IBAction on my UICollectionViewCell class, I cannot open a new viewcontroller.
I try to add a delegate method on my actual viewcontroller, like
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath),
but when i "click" on an item, it doesn't perfom method.
I'm checked every parameter and setting, all seems to be ok. I don't know what I have to try more.
Thank you for your time.
Is there a way I can use collectionView reloadData on this collection view? Every time I try to reload the data I get an error like this : 'UICollectionView received layout attributes for a cell with an index path that does not exist:
I am trying to include a search feature to filter collection results but it keeps breaking.
Any ideas on this?
This is solved
Hello, and thanks for this great code!
I'm trying to add a header to the view, using the following:
collectionView .registerNib(UINib(nibName: "HeaderMulticolumn", bundle: nil), forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "Header")
then later, implement the delegate methods:
func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
let headerView = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "Header", forIndexPath: indexPath)
headerView.backgroundColor = UIColor.blueColor();
return headerView
}
and in the layout class
override func layoutAttributesForSupplementaryViewOfKind(elementKind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
let attributes = UICollectionViewLayoutAttributes(forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withIndexPath: indexPath)
let headerHeight = CGFloat(50)
attributes.frame = CGRectMake(0, 0, self.collectionView!.frame.size.width, headerHeight)
return attributes;
}
It's not necessarily a question about your code, but I can't get collectionView: viewForSupplementaryElementOfKind: to be called at all. Is there any chance you could point at the right direction to have Headers added to your custom UICollectionView class?
note: I tried with different layout classes, without changing the controller class, and managed to have headers added, so it must come from the way CustomCollectionViewLayout operates (but I can't see why)
thanks!
Hi,
I am trying to using this library in Xcode 9.3.
When I increase or decrease the column it gets crashed. Please let me know what need to do?
Thanks,
Rahul Gupta
// Tip: If we don't know the number of columns we can call the following method and use the NSUInteger object instead of the NUMBEROFCOLUMNS macro
NSUInteger numberOfItems = [self.collectionView numberOfItemsInSection:section];
where does this section
variable come from?
How can I get that same vertical line that is showing in the .gif preview after the sticky column
So I used this piece of code, to make the last section stick to the bottom:
if (section == [self.collectionView numberOfSections]-1)
{
CGRect frame = attributes.frame;
frame.origin.y = self.collectionView.contentOffset.y + self.collectionView.frame.size.height - 30;
attributes.frame = frame;
}
But, if the last section is pinned to bottom, the collectionview is not able to scroll. If I change frame.origin.y = self.collectionView.contentOffset.y + self.collectionView.frame.size.height - 30;
, to frame.origin.y = self.collectionView.contentOffset.y + self.collectionView.frame.size.height + 70;
It scrolls little bit downwards until the last section is visible and stops there.
In the Objective-C version of CustomCollectionViewLayout.m, inside the prepareLayout method, following code is written:
// Tip: If we don't know the number of columns we can call the following method and use the NSUInteger object instead of the NUMBEROFCOLUMNS macro
// NSUInteger numberOfItems = [self.collectionView numberOfItemsInSection:section];
prepareLayout, will be called everytime the bounds change. In that case what would be the value of "section" variable for "numberOfItemsInSection:section". I can't see to find it. If I uncomment it, in my code, it gives error, if I use your file, everything is fine.
I just copied the demo's .m file into my project's .m file
I find that if you touch fastly and move diagonally, even if I set Direction Lock Enabled
, the table still scroll in both two direction.
any ideas?
thanks for you time.
Hi,
I used CustomCollectionViewLayout in my app. i have to maintain the constant width for few columns. by using the width when the text is increased the section height need to be increase . Please give the suggestions to implement dynamic section height to display all the rows in that section contain same height.(Like excel page).
Thank you
How can I make dynamic columns in this customcollectionViewLayout
I am trying to figure out if its possible to create a swipe to delete method for an entire row using this script.
I understand each row is made up of many cells, would there be a way to hit the collection view layout and make all cells go one way when swiping?
Hi,
I am using CustomCollectionViewLayout in my project. when text is entered in the row the cell height need to adjust automatically like excel sheet . please give suggestions to implement this
Line 183 - CGSize size = [text sizeWithAttributes: @{NSFontAttributeName:[UIFont numercoFontRegularWithSize:15]}];
Can you please update this code for swift3
I try to make header stick when scrolling up and move down with other when contentOffset.y < 0. It works when scrolling slowly but when scroll so fast header move the wrong frame.
Any suggestion help me out of this?
Thanks.
If I add a button that is removing some section, it is crashing after scrolling to last section:
@IBAction func didClick(sender: AnyObject) {
numberOfSections -= 1;
let set = NSIndexSet(index: 2)
self.collectionView.deleteSections(set)
}
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0xc000000000003116> {length = 2, path = 49 - 0}'
Can you help me how to resolve this issue?
Hello, i'm new in swift programming
I see in your example this
contentCell.contentLabel.text = "Content"
that was code for set the cell content right?
So, what if i have data that need looping?
Did i just go "for" then inside the looping insert this
contentCell.contentLabel.text = thearray
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.