0

I'm using RFQuiltLayout in for my uicollectionview.

My storyboard contain Uiview + collectionview. collectionview are IBOutleted to my UiView class and in my storyboard i'm using custom layout for my collectionview like this :

enter image description here

I'm loading my collectionview data from appdelegate class so in first run it return 0 for numberOfItemsInSection and after data get fetched from server it will load my collectionview.

Now problem is if i change the Layout to flow program works correctly but if i use custome class like RFQuiltLayout no cell shows up ,

numberOfItemsInSection returns my actual value but cellForItemAtIndexPath not getting called.

The code in my ViewDidLoad:

   self.CV.delegate = self;
    self.CV.dataSource = self;
    [self.CV registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"MyCell"];

    RFQuiltLayout* layout = (id)[self.CV collectionViewLayout];
    layout.direction = UICollectionViewScrollDirectionVertical;
    layout.blockPixels = CGSizeMake(75,75);

I'm also calling reloaddata in viewDidAppear.

and in appdelegate:

   ParseOperation *weakParser = parser;
    parser.completionBlock = ^(void) {
        if (weakParser.appRecordList) {
            dispatch_async(dispatch_get_main_queue(), ^{

           MyCollectionViewController *rootViewControllers = (MyCollectionViewController*)[(UINavigationController*)self.window.rootViewController topViewController];
                rootViewControllers.entries = weakParser.appRecordList;
               [rootViewControllers.CV.collectionViewLayout invalidateLayout]; 
               [rootViewControllers.CV reloadData];
            });
        }

one thing is if i use this code in my delegate the uicollection shows up but without any custome layout and scrolling ability :

            [rootViewControllers.CV reloadData];
            NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
            NSIndexPath *indexPath;
            for (int i = 0; i < [weakParser.appRecordList count]; i++) {
                indexPath = [NSIndexPath indexPathForItem:i inSection:0];
                [indexPaths addObject:indexPath];
            }

            [rootViewControllers.CV reloadItemsAtIndexPaths:indexPaths];

the methods inside RFQuiltLayout gets called but the method for layout inside

uiview like these "blockSizeForItemAtIndexPath" and

"blockSizeForItemAtIndexPath" not getting called.

2
  • You probably need to create the layout. Check out [this post][1]. [1]: stackoverflow.com/questions/21664555/… Commented Mar 9, 2015 at 6:59
  • i dont think thats the case because collection view and its layout have been initialised from a storyboard.also i put some nslog inside layout and the layout functions are called inside RFQuiltLayout. Commented Mar 9, 2015 at 7:12

1 Answer 1

1

You don't need to register the class again in your didload. I guess this is the reason behind your issue. Go to you Storyboard and select your CollectionViewCell and change its class to your custom class. And remove this line from your didLoad [self.CV registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"MyCell"];

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.