gpt4 book ai didi

ios - 解析的 UICollectionViewController 问题

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

我的 Parse 数据库中有数据,我正在尝试检索该数据并将其显示到 UICollectionViewCell 下的 UILabel 中。

-(void)viewDidLoad {
[super viewDidLoad];
PFQuery *retrieveClass = [PFQuery queryWithClassName:@"ClassName"];
[retrieveClass findObjectsInBackgroundWithBlock:^(NSArray *objets, NSError *error) {

if (!error) {
classArray = [[NSArray alloc] initWithArray:objets];
NSLog(@"%@", objets);
}
}];
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {

return 1;
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

return classArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];

PFObject *tempDict = [classArray objectAtIndex:indexPath.row];

cell.label.text = [tempDict objectForKey:@"Name"];
NSLog(@"%@",[tempDict objectForKey:@"Name"]);

return cell;
}

classArray 是一个 NSArray,我创建了一个 UICollectionViewCell 文件并创建了一个 UILabel,然后导入到我的主文件中。

我添加了单元标识符,建立了连接,但我不知道哪里出了问题。

类名是正确的,字段名是正确的,解析 ID 和 ClientKeys 是正确的。

我在查询 block 下收到日志反馈,但在 UICollectionViewCell 下没有任何反馈。

日志输出 enter image description here

最佳答案

改变这一行

cell.label.text = [classArray objectAtIndex:indexPath.row];

cell.label.text = [tempDict objectForKey:@"Name"];

关于ios - 解析的 UICollectionViewController 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34647242/

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