简体   繁体   中英

- (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath not called

I have this two delegate:

#pragma mark = UICollectionViewDataSource

- (NSInteger)collectionView:(UICollectionView*)collectionView numberOfItemsInSection:(NSInteger)section
{
    NSLog(@"COUNT IS %d", [[AHImageDataSource sharedDataSource] count]);
    return [[AHImageDataSource sharedDataSource] count];
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView
{
    return 1;
}

numberOfItemsInSection returned 12. but the cellForItem is not called. When I just hardcode the numberOfItemsInSection, it actually is getting called. Any idea of why this weird issue is hapening?

Here's a sample project demonstrating the issue

If [[AHImageDataSource sharedDataSource] count] is returning nil , cellForItemAtIndexPath will not get called. So please make sure that [[AHImageDataSource sharedDataSource] count] has some value.

I'm not able to download your sample project, so can't help much. :(

Did you set the delegate?..

Be sure that the method name is correct or you are missing something..

The file PintCollectionViewLayout.m was not included in the Compile Sources in the target's Build phase. Add that, resolved the issue for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM