bryceredd / rfquiltlayout Goto Github PK
View Code? Open in Web Editor NEWA UICollectionViewLayout subclass to put items in a quilting pattern
License: MIT License
A UICollectionViewLayout subclass to put items in a quilting pattern
License: MIT License
Carthage 0.15.2 reports this error when attempting to build RFQuiltLayout:
Dependency "RFQuiltLayout" has no shared framework schemes for any of the platforms: iOS
I wanted 3 boxes in a single row with the same size. When user taps on any box, it must get enlarged & the other items have to get aligned accordingly.
I am using the same code given in RFQuiltLayout, but made a few changes as given below.
- (void)viewDidLoad {
.....
RFQuiltLayout* layout = (id)[self.collectionView collectionViewLayout];
layout.direction = UICollectionViewScrollDirectionVertical;
layout.blockPixels = CGSizeMake(97,97);
[self.collectionView reloadData];
}
- (void) setNumberArrays {
[self.numbers removeAllObjects];
[self.numberWidths removeAllObjects];
[self.numberHeights removeAllObjects];
for (NSInteger i = 0; i< [[self.entries objectAtIndex:0] count]; i++) {
[self.numbers addObject:@(i)];
if (i == AppDelegateObj.bigBoxIndex) {
[self.numberWidths addObject:@(2)];
[self.numberHeights addObject:@(2)];
}
else {
[self.numberWidths addObject:@(1)];
[self.numberHeights addObject:@(1)];
}
}
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (AppDelegateObj.bigBoxIndex == -1) {
AppDelegateObj.bigBoxIndex = indexPath.row;
}
else {
AppDelegateObj.bigBoxIndex = -1;
}
[self setNumberArrays];
if(!self.numbers.count || indexPath.row > self.numbers.count) return;
if(isAnimating) return;
isAnimating = YES;
[self.collectionView performBatchUpdates:^{
[self.collectionView reloadData];
} completion:^(BOOL done) {
isAnimating = NO;
}];
}
When user taps on a box, I am just reassigning the arrays 'self.numbers', 'self.numberWidths', 'self.numberHeights' & reloading the UICollectionView.
Suppose user taps on 2, as per the current code the below is happening,
But I want the output to look like,
Please suggest what is the change to be made on code. I tried a lot to change. But failed :(
I am trying to create sections in my view controller with respect to the QuiltViewLayoutDelegate, however it doesn't work. I am using your demo and edited the method numberOfSectionsInCollectionView. Is the problem within your third party? If so where can i find it?
Set a larger size for the UICollectionViewCells, horizontal scrolling and default 50 objects. Scroll to the end of the UICollection. Tap the Add button. You will see the the UICollectionViewCells disappearing (38 - 43) and came back on when you tap the Add button again. Any suggestion how to fix / debug this?
This is what I set for RFViewController's viewDidLoad, layout.blockPixels = CGSizeMake(310, 225), and at blockSizeForItemAtIndexPath returning only CGSizeMake(1.0, 1.0).
Hi,
I'm a iOS newbie and have a Swift project, how do I use RFQuiltLayout
with it? Do I import it via ProjectName-Bridging-Header
? I've copied RFQuiltLayout.m & RFQuiltLayout.h files to a folder within my project and then called #import "RFQuiltLayout.h"
in the Bridging-Header file. However, when I try to change the Custom Class for the Collection View Flow Layout of a Collection View, RFQuiltLayout doesn't show up.
Hi, I use your Layout but if I want show multiple sections with headers, it's not posible, because the header section never get call. What I need to do to show multiple sections and headers??
Thanks iun advance
Anyone know of equivalent project for Android using RecyclerView?
It must not use any pre-defined patterns.
RFQuiltLayout is using bin-packing algorithm, isn't it?
Whenever I call reloadData and I add a couple more cells the view jumps back to some start cell. This causes the experience to be really bad and feels horrible
I am laying out my block size using this
- (CGSize)blockSizeForItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row % 7 == 0){
return CGSizeMake(3, 3);
}
else if(indexPath.row % 5 == 0)
return CGSizeMake(2, 1);
return CGSizeMake(1, 1);
}
Dear Sir
I realised that the layout chooses the best fit space to calculate position of the next element, how to make a minor change to make the position of elements by their ordinary order (to the last of the elements)
Thanks
Would you mind updating the cocoapod? It is severely out of date
I believe the collectionViewContentSize should return the full size of the layout. Right now it only returns down to the furthestBlockPoint+1, so If you just load the layout, and haven't scrolled down, the content size is incorrect. This causes the scrolling indicators to jump around as you scroll and layout the rest of the cells.
I assume you are planning to implement something like this due to the unused 'prelayoutEverything' property.
I can try to take a stab at fixing it, but I will have to familiarize myself with the code, let me know if you have any suggestions.
Hello, How can I use this library without storyBoard ( because in my code I'm drawing tableView programmatically ) , I tried something like this but didn't worked and MyCollectionView never called and layout is always nil :
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
//self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.collectionView];
[_collectionView registerNib:[UINib nibWithNibName:@"myCell" bundle:nil] forCellWithReuseIdentifier:@"cell3"];
[_collectionView setBackgroundColor:[UIColor colorWithRed:0.945 green:0.945 blue:0.945 alpha:1] ];
[_collectionView setTransform:CGAffineTransformMakeScale(-1, 1)];
RFQuiltLayout* layout = (id)[_collectionView collectionViewLayout];
layout.direction = UICollectionViewScrollDirectionVertical;
layout.blockPixels = CGSizeMake(100, 100);
}
- (UICollectionView *)collectionView {
if (!_collectionView) {
CGRect collectionViewFrame = self.view.bounds;
collectionViewFrame.size.height -= (self.navigationController.viewControllers.count > 1 ? 0 : (CGRectGetHeight(self.tabBarController.tabBar.bounds))) + 0;
// FMMosaicLayout *mosaicLayout = [[FMMosaicLayout alloc] init];
//// _collectionView = [[UICollectionView alloc] initWithFrame:collectionViewFrame collectionViewLayout:mosaicLayout];
// RFQuiltLayout* layout = (id)[_collectionView collectionViewLayout];
// layout.direction = UICollectionViewScrollDirectionVertical;
// layout.blockPixels = CGSizeMake(100, 100);
_collectionView = [[UICollectionView alloc] initWithFrame:collectionViewFrame collectionViewLayout:[[RFQuiltLayout alloc] init]];
_collectionView.delegate = self;
_collectionView.dataSource = self;
}
return _collectionView;
}
Is there anyway to make RFQuiltLayout with multiple section?
We all use content inset on top and bottom for both UITableView and UICollectionView for several purposes.
But here contentInset is missing.. If we have a property for setting the contentInset, that would be great.
Hello I've spent a bit of time on this and can't seem to wrap my hear around it. I am using RFQuiltLayout with a menu that alternates it between a rear and front view controller. When I bring the RFQuiltLayout from the rear to the front again, the view controller does not reload the quilt and is just black. I noticed the example contained:
Which I thought would refresh the quilt. Any ideas or pointers would be greatly appreciated.
Thank you
Why not head size
This is more open for discussion than an issue. The current way to use RFQuiltLayout requires a block size which can take a long time to load if set to low numbers. I wonder if there is another way to do this that uses the regular cell sizes but is fast with a lot of small cells.
Hey, I'm just wondering how I should use this for printing labels inside the cells.
If I return the label size in the blockSizeForItemAtIndexPath: method it makes the cell way to big because its multiplying it by the blockPixels or something of that nature.
Any ideas?
M
Hello,
I have been playing with RFQuiltLayout.
Basically I need a layout like ZigZag tiles, something like this
|^|
|^|
|**^|
The first three rows gets drawn properly but later it auto resize the tiles and start messing with it.
Anyone can help?
Here is the code:
int counter = 4;
- (CGSize) blockSizeForItemAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"%d and Row: %d",counter % 4, indexPath.row);
if(counter % 4 >= 2)
{
counter++;
if(indexPath.row >= self.numbers.count)
NSLog(@"Asking for index paths of non-existant cells!! %d from %d cells", indexPath.row, self.numbers.count);
if (indexPath.row % 2 == 0) {
return CGSizeMake(2, 1);
}else
{
return CGSizeMake(1, 1);
}
}
else
{
counter++;
if(indexPath.row >= self.numbers.count)
NSLog(@"Asking for index paths of non-existant cells!! %d from %d cells", indexPath.row, self.numbers.count);
if (indexPath.row % 2 == 0) {
return CGSizeMake(1, 1);
}else
{
return CGSizeMake(2, 1);
}
}
}
Hello. Please make delegate methods of the layout to apple style, for easy manage of multiple collection views.
Delegate mehtods:
Hi everybody, thanks for such a good framework like this.
I have a problem when I try to form something like this:
This is the code I've used:
While using horizontal scrolling, even though collection view origins at (0,0), full screen size, there's space added to the top and bottom. How can we remove that
TIA
When I tested this the demo app crashes when you remove all items and attempt to add one. I believe this happens because you mod by 0 in your add method. Just a heads up.
Hello,
It seems that in iOS 8 RFQuiltLayout is not working well, it resize the space of each cell but the cell is not resizing at all.
What is the problem here?
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.