A view that display cells like spreadsheet.
##Requirements
iOS 6.0 or later
##Installation via CocoaPods
pod 'TAXSpreadSheet'
##Usage
Import header
#import "TAXSpreadSheet.h"
Instantiate TAXSpreadSheet and register UICollectionViewCell or subclass for cells the same as UICollectionView.
TAXSpreadSheet *spreadSheet = [[TAXSpreadSheet alloc] initWithFrame:CGRectMake(0.0. 0.0. 100.0, 100.0)];
[spreadSheet registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
Set DataSource and Delegate objects and implement those methods.
- (NSUInteger)numberOfColumnsInSpreadSheet:(TAXSpreadSheet *)spreadSheet
{
return 10;
}
- (NSUInteger)numberOfRowsInSpreadSheet:(TAXSpreadSheet *)spreadSheet
{
return 20;
}
- (UICollectionViewCell *)spreadSheet:(TAXSpreadSheet *)spreadSheet cellAtRow:(NSUInteger)row column:(NSUInteger)column
{
UICollectionViewCell *cell = [spreadSheet dequeueReusableCellWithReuseIdentifier:@"Cell" forRow:row column:column];
// Customize cells.
return cell;
}
You should return dequeued UICollectionViewCell subclass from SpreadSheet in spreadSheet:cellAtRow:column
##Customize
###Specifying individual metrics You can specify individual heights of row, width of column, inter-row/column spacing by implementing delegate methods. In case of using default value, return NSNotFound.
- (CGFloat)spreadSheet:(TAXSpreadSheet *)spreadSheet heightAtRow:(NSUInteger)row
{
if (row == 0) {
return 100.0;
} else {
return 50.0;
}
}
###Use custom views for inter-row/column. You can use custom UICollectionReusableView subclass for inter-row/column by implementing delegate methods. You should register class and dequeue view from SpreadSheet. In case of not using view, return nil.
- (UICollectionReusableView *)spreadSheet:(TAXSpreadSheet *)spreadSheet interRowViewBelowRow:(NSUInteger)row
{
if (row == 0) {
UICollectionReusableView *view = [spreadSheet dequeueReusableInterRowViewWithIdentifier:@"View" belowRow:row];
return view;
} else {
return nil;
}
}
##License
MIT License
##Change Log ###0.2.0
- [Add] UICollectionView/Layout compatible methods.
- [Add] Forwarding UICollectionViewDelegate methods.
- [Add] backgoundView property.
- [Fix] backgroundColor property.
###0.2.1
- [Fix] Crash when number of rows or columns become zero.