gpt4 book ai didi

iphone - collectionView dequeueReusableCellWithIdentifier 出错

转载 作者:行者123 更新时间:2023-11-28 20:20:59 25 4
gpt4 key购买 nike

我在将 uitable 转换为 collectionview 时遇到了问题。

我有以下代码,但它在“collectionView dequeueReusableCellWithIdentifier”上有错误我可以知道是什么问题吗?

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

// Return the number of rows in the section (the amount of items in our array)
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [pictureListData count];
}

// Create / reuse a table cell and configure it for display
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";

UICollectionViewController *cell = [collectionView dequeueReusableCellWithIdentifier:CellIdentifier];


// Get the core data object we need to use to populate this table cell
Pictures *currentCell = [pictureListData objectAtIndex:indexPath.row];

最佳答案

你有错误的方法名称。对于 UICollectionViews,方法是:

- (id)dequeueReusableCellWithReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath*)indexPath

所以你需要改变

UICollectionViewController *cell = [collectionView dequeueReusableCellWithIdentifier:CellIdentifier];

UICollectionViewController *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];

关于iphone - collectionView dequeueReusableCellWithIdentifier 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16038684/

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