Skip to content

Instantly share code, notes, and snippets.

@PhilipBale
Created August 26, 2015 14:05
Show Gist options
  • Save PhilipBale/dc5840fc1c96bceba588 to your computer and use it in GitHub Desktop.
Save PhilipBale/dc5840fc1c96bceba588 to your computer and use it in GitHub Desktop.
Form descprition
@interface CreateEventViewController ()
@property(nonatomic, strong) FORMDataSource *sourceData;
@end
@implementation CreateEventViewController
- (FORMDataSource *)dataSource {
if (_sourceData) return _sourceData;
NSArray *JSON = [NSJSONSerialization JSONObjectWithContentsOfFile:@"CreateEvent.json"];
_sourceData = [[FORMDataSource alloc] initWithJSON: JSON
collectionView:self.collectionView
layout:[FORMLayout new]
values:nil
disabled:NO];
__weak typeof(self)weakSelf = self;
_sourceData.configureCellBlock = ^(FORMBaseFieldCell *cell, NSIndexPath *indexPath, FORMField *field) {
cell.field = field;
};
_sourceData.fieldUpdatedBlock = ^(FORMBaseFieldCell *cell, FORMField *field) {
};
return _sourceData;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.collectionView.dataSource = self.dataSource;
self.collectionView.contentInset = UIEdgeInsetsMake(20.0f, 0.0f, 0.0f, 0.0f);
}
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return [self.dataSource sizeForFieldAtIndexPath:indexPath];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment