gpt4 book ai didi

ios - 未调用 UICollectionView cellForItemAtIndexPath 方法

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:14:11 27 4
gpt4 key购买 nike

cellForItemAtIndexPath 未被调用。我觉得一切都很正常有什么问题?

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

-(NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CollectionViewCell *cell=(UICollectionView *)[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];

cell.titleText.text=@"test";

return cell;
}

最佳答案

在您的 viewDidLoad 方法中,您可能想要添加:

self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.collectionView reloadData];

就这么简单。

关于ios - 未调用 UICollectionView cellForItemAtIndexPath 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31696649/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com