Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using library without storyBoard #31

Open
chlebta opened this issue Mar 16, 2015 · 0 comments
Open

Using library without storyBoard #31

chlebta opened this issue Mar 16, 2015 · 0 comments

Comments

@chlebta
Copy link

chlebta commented Mar 16, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant