Skip to content

Using library without storyBoard #31

@chlebta

Description

@chlebta

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions