filletofish / cardslayout Goto Github PK
View Code? Open in Web Editor NEW:star: Custom card-designed CollectionView layout
License: MIT License
:star: Custom card-designed CollectionView layout
License: MIT License
Basically like this
I am trying to shift the cells behind the first one in order to better see the other content.
cell is scroll by swiping left or right but i want to scroll on button click. can any one please help me out.
Hello and thanks for this great Collection Layout ! ๐
I have a question, is it being considered to handle infinite scroll ?
By infinite scroll I mean, when you scroll a card to the left, it appears at the end of the list.
Thanks in advance
Im trying to use CardsLayout, for iPhone 6 and up looks good, but iPhone 5 the cell doesn't adjust to the layout.
Hi, i have implemented lib in my app now when i try to swipe card they aren't working not even its selection function is working, it looks like it get stuck, other application is working fine but CardsLayout is stuck, how can i resolve this? My code for calling CardsLayout is this,
//Collection View Reload self.knowledgeCollectionView.collectionViewLayout = CardsCollectionViewLayout() self.knowledgeCollectionView.isPagingEnabled = true self.knowledgeCollectionView.showsHorizontalScrollIndicator = false
I have passed it to my collection view, at first it was working now i have tried code after a long time it get stuck. Please help me in this.
Can you add rotate in and rotate out animation just like tinder
Is there a way to only swipe to next card? The user should not be able to scroll back to previous card. Also, is there a way to swipe away the last card?
Hi , i have used ur library in my collection view, i have mad my custom collection view have a single image on cell. I have passed all the data source and delegate this is my code,
//Collection View Reload self.knowledgeCollectionView.collectionViewLayout = CardsCollectionViewLayout() self.knowledgeCollectionView.isPagingEnabled = true self.knowledgeCollectionView.showsHorizontalScrollIndicator = false self.knowledgeCollectionView.reloadData()
` override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return cardsArray.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = knowledgeCollectionView.dequeueReusableCell(withReuseIdentifier: "knowledgeCell", for: indexPath) as! KnowledgeCVC
cell.cardImage.image = cardsArray[indexPath.row]
return cell
}`
But when i call my VC the app crashes on a delegate written in ur library,
` // MARK: - UICollectionViewDelegateFlowLayut
@objc open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
guard let cellWidthValue = cachedCellWidths?[indexPath.row] else {
fatalError("cachedCellWidths for \(indexPath.row) must not be nil")
}
return CGSize(width: cellWidthValue, height: collectionView.frame.size.height)
}`
Error is Thread 1: Fatal error: Index out of range
. How i can get rid of this?
Hi thanks for your excellent repository i just want to have this thing how to
change the swipe direction i want the cards to swipe up and down.
how to make it auto scroll?
i use collectionView.scrollToItem(at: next, at: .centeredHorizontally, animated: true)
but it's not work~
Hi, i have implemented your library in my collection view and when i run the app it shows cards size very small. How can library get the size my collection view cell size? This is my code,
//Collection View Reload self.knowledgeCollectionView.collectionViewLayout = CardsCollectionViewLayout() self.knowledgeCollectionView.isPagingEnabled = true self.knowledgeCollectionView.showsHorizontalScrollIndicator = false
Unable to use scrollToItem it just keeps showing the current item.
Hi, before all, awesome work.
I will like to block the user to swipe the card manually and do it programmatically, when I considere necessary, like a stepper. is this possible?
Not sure if this is up to your library but I'll try nevertheless.
I'm using CardsCollectionViewLayout in my code via Swift Bridging for my CollectionView.
My issue is that IndexPath
is returning wrong Item index. Here is the minimal code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.collectionViewEvents.collectionViewLayout = [[CardsCollectionViewLayout alloc] init];
self.collectionViewEvents.dataSource = self;
self.collectionViewEvents.delegate = self;
self.collectionViewEvents.pagingEnabled = YES;
self.collectionViewEvents.showsHorizontalScrollIndicator = NO;
[self load];
}
// Issue visible here, the indexPath.item is not correct
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
for (UICollectionViewCell *cell in self.collectionViewEvents.visibleCells) {
NSIndexPath *indexPath = [[self collectionViewEvents] indexPathForCell:cell];
NSLog(@"Visible Cell IndexPath Item %ld", indexPath.item);
return;
}
}
- (void)load
{
// self.eventData is declares as: @property (nonatomic) NSArray *eventData;
self.eventData = [[NSArray alloc] initWithObjects:UIColor.blackColor, UIColor.whiteColor, UIColor.brownColor, nil];
[[self collectionViewEvents] reloadData];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionViewCellReuseIdentifier"
forIndexPath:indexPath];
cell.layer.cornerRadius = 7.0;
cell.backgroundColor = UIColor.blackColor;
return cell;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.eventData.count;
}
Result (notice how both 1st and 2nd cell has same IndexPath Item):
2020-03-19 14:48:05.334905+0100 App[7422:2617858] Visible Cell IndexPath Item 2 # => 3rd cell
2020-03-19 14:48:05.741805+0100 App[7422:2617858] Visible Cell IndexPath Item 1 # => 2nd cell
2020-03-19 14:48:06.184932+0100 App[7422:2617858] Visible Cell IndexPath Item 1 # => 1st cell
I tried your Example from this code Repository, which has declared colors statically:
var colors: [UIColor] = [
UIColor(red: 237, green: 37, blue: 78),
UIColor(red: 249, green: 220, blue: 92),
UIColor(red: 194, green: 234, blue: 189),
UIColor(red: 1, green: 25, blue: 54),
UIColor(red: 255, green: 184, blue: 209)
]
...
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCellReuseIdentifier", for: indexPath)
cell.layer.cornerRadius = 7.0
cell.backgroundColor = .black
return cell
}
And after implementing this code below, it returns proper IndexPath.
// Issue NOT visible here, the indexPath.item IS correct
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
for cell in collectionView.visibleCells {
let indexPath = collectionView.indexPath(for: cell)
print(indexPath?.item)
return
}
}
Result:
2020-03-19 14:48:05.334905+0100 App[7422:2617858] Visible Cell IndexPath Item 2 # => 3rd cell
2020-03-19 14:48:05.741805+0100 App[7422:2617858] Visible Cell IndexPath Item 1 # => 2nd cell
2020-03-19 14:48:06.184932+0100 App[7422:2617858] Visible Cell IndexPath Item 0 # => 1st cell
What am I doing wrong in my Objective-C
code?
// 1st cell has index 1, instead of 0
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
for (UICollectionViewCell *cell in [[self collectionViewEvents] visibleCells]) {
NSIndexPath *indexPath = [[self collectionViewEvents] indexPathForCell:cell];
NSLog(@"Visible Cell IndexPath Item %ld", indexPath.item);
return;
}
// 1st cell has index 1, instead of 0
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSArray *visible = [self.collectionViewEvents indexPathsForVisibleItems];
NSIndexPath *indexPath = [visible firstObject];
NSLog(@"Visible Cell IndexPath Item %ld", indexPath.item);
return;
// Calling it in main thread, same result
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
dispatch_async(dispatch_get_main_queue(), ^{
for (UICollectionViewCell *cell in [[self collectionViewEvents] visibleCells]) {
NSIndexPath *indexPath = [[self collectionViewEvents] indexPathForCell:cell];
NSLog(@"Visible Cell IndexPath Item %ld", indexPath.item);
return;
}
});
Hi! I have tried to play with the pod in Xcode project, but it turned out that the pod can not be resolved.
Here's output of pod install
command:
โ CardsTest pod install
Analyzing dependencies
[!] Unable to find a specification forCardsLayout
Same for pod install --repo-update
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.