gpt4 book ai didi

ios - UICollectionView 没有调用 didSelectItemAtIndexPath

转载 作者:行者123 更新时间:2023-12-01 17:31:03 26 4
gpt4 key购买 nike

我有一个 Collection View ,其中有带有图像和标签的自定义单元格。我已将我的收藏 View 设置如下 -

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
flowLayout.minimumLineSpacing = 150.0f;
flowLayout.minimumInteritemSpacing = 104.0f;
flowLayout.sectionInset = UIEdgeInsetsMake(20, 20, 100, 120);

_archiveCollectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
_archiveCollectionView.frame = CGRectMake(30, 218, _archiveCollectionView.frame.size.width - 60, _archiveCollectionView.frame.size.height - 350);
_archiveCollectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_archiveCollectionView.backgroundColor = [UIColor clearColor];
_archiveCollectionView.delegate = self;
_archiveCollectionView.dataSource = self;
[self.archiveCollectionView registerNib:[UINib nibWithNibName:@"FullArchiveEditionCell" bundle:nil] forCellWithReuseIdentifier:@"MyCell"];

[_archiveCollectionView reloadData];
[self.view addSubview:_archiveCollectionView];

我还设置了以下方法:
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return _chosenCategoryArray.count;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[self addEditionsChildView];
}
-(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}

但是,我的 didSelectItemAtIndexPath当我选择一个单元格时,永远不会被调用。请问有什么帮助吗?

最佳答案

我有一个类似的问题,结果我在两个不同的 Collection View 中使用了相同的单元重用标识符

关于ios - UICollectionView 没有调用 didSelectItemAtIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22565286/

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