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.

Ahad Porkar
  • 1,666
  • 2
  • 33
  • 68
  • You probably need to create the layout. Check out [this post][1]. [1]: http://stackoverflow.com/questions/21664555/rfquiltlayout-and-uicollectionview – amahfouz Mar 09 '15 at 06: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. – Ahad Porkar Mar 09 '15 at 07:12

1 Answers1

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"];

Ashraf Tawfeeq
  • 3,036
  • 1
  • 20
  • 34